connect_error) { die("Connection failed: " . $con->connect_error); } if (!$con->query("SELECT PASSWORD FROM data WHERE USERNAME = '".$username."'")) { /* MySQL check if the MySQL is not correct */ printf("Error: %s\n", $con->error); } $query = "SELECT PASSWORD FROM data WHERE USERNAME = '".$username."'"; /* Gets the password from the table "data" where the username submitted is equal to some username in the database */ $result = $con->query($query); if ($result->num_rows > 0) { /* If the username matches in the database... */ while ($row = $result->fetch_assoc()) { $password_unhashed = password_verify($password, $row['PASSWORD']); /* Unhashes the password */ if ($password_unhashed == true) { /* If the password matches the unhashed password from the database... */ echo "Found data in the database! Visit the chat by clicking your username (see the button)."; echo "
"; /* Button that leads the user to the chat. */ } else { echo "Password is incorrect! Please try again."; /* If the password was incorrect send an error message. */ } } } else { echo "Username not found/password incorrect. Please try again!"; /* Error message if the username was not found. */ } $con = null; exit; ?> Home