title: php username and password checking won't work
body: <p>i'm trying to make a login page work with php and mysql, but it doesn't wanna work, i'm new to php.
  All i want is when a correct user and pass is entered, display/echo that user's level </p>
  
  <p>mysql:<a href="https://i.stack.imgur.com/xJbBk.png" rel="nofollow noreferrer">image</a></p>
  
  <p>db.php: </p>
  
  <pre><code>&lt;?php
  $servername = "127.0.0.1";
  $username = "root";
  $password = "";
  $dbname = "maindb";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  # open database like before.
  $web_username=$_POST['username'];
  if ($web_username=="") die(); # one bit of error handling.
  $web_password=$_POST['password'];
  $sql = "SELECT id, level FROM users WHERE name = ? AND password = ?";
  $stmt =  $conn-&gt;prepare ($sql ); # needs error check
  $stmt-&gt;bind_param("ss", $web_username, $web_password);
  $stmt-&gt;execute(); # needs error check
  if ($stmt-&gt;num_rows==1) {
      $stmt-&gt;bind_result($id, $level);
      $stmt-&gt;fetch(); 
      printf ("id is %s, level is %s\n", $id, $level);
  }
  ?&gt;
  </code></pre>
  
  <p>index.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form method='post' action='db.php'&gt;
  Username: &lt;input type='text' name='username' placeholder='username'&gt;&lt;br&gt;
  Password: &lt;input type='password' name='password' placeholder='password'&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>