i am making an login script who is connected to a database but i get an
"Undefined variable: dbUsername in F:\xamp\register\login\functions.php on line 21"
I have further checked it and i saw that my query doesn't work can you guys help me?
if (isset($_POST['sub']))
{
include_once("Connect.php");
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$sql = "SELECT id, username, password FROM login WHERE username = '$username' LIMIT 1";
$query = mysqli_query($dbcon, $sql);
if ($query) {
$row = mysqli_fetch_row($query);
$userId = $row[0];
$dbUsername = $row[1];
$dbPassword = $row[2];
}
if ($username == $dbUsername && $password == $dbPassword) {
$_SESSION['username'] = $username;
$_SESSION['id'] = $userId;
header('location: login.php');
} else {
echo "incorrect username or password.";
}
}