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.
Thanks!
<?php
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$existing = "";
$something = "The username or password is not correct";
$sql = "SELECT * FROM users WHERE username='$username' && password='$password'";
require_once ('db.php');
$qry=mysqli_query($conn, $sql) or die ("Error");
$count = mysqli_num_rows($qry);
if($count==1) {
setcookie($username);
}
else {
$output = $something;
}
}
?>