title: How to check my username on phpmyadmin with cookies
body: <p>I want to make a login page, if the use type the username and password correctly, it will rediret to the two factor authentication page. I want every user have a different qr code, but my problem is how the website know which user I type. I also want to set when the user is first time to login, it will show the qrcode let the user scan, if the user login after first time,it won't show the qrcode, how to set it, and fix that problem.</p>
  <p>Thanks!</p>
  <pre><code>&lt;?php
  if (isset($_POST['login'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $existing  = &quot;&quot;;
      $something = &quot;The username or password is not correct&quot;;
  
    $sql = &quot;SELECT * FROM users WHERE username='$username' &amp;&amp; password='$password'&quot;;
    require_once ('db.php');
    $qry=mysqli_query($conn, $sql) or die (&quot;Error&quot;);
    $count = mysqli_num_rows($qry);
  
      if($count==1) {
      setcookie($username);
    }
    else {
      $output = $something;
    }
  
  }
  
  ?&gt;
  </code></pre>