0
I have this code to compare the email and password that are in the database, but it is always possible that the data is wrong, not letting in. What’s wrong with the code, can help me?
<?php
$servername = "localhost";
$username = "isabelso_isabel";
$password = "password";
$dbname = "isabelso_db";
$dbconn = mysqli_connect($servername, $username, $password, $dbname)or die("Failed to connect to database:" . mysqli_error($conn));;
//Get user details and put them on varaiables
$email = mysqli_real_escape_string($dbconn, $_POST['login']);
$password = mysqli_real_escape_string($dbconn, $_POST['senha']);
if (!empty($email) && !empty($password))
{
$query = "SELECT * FROM Paciente WHERE email = '$email' AND password = '$password'";
$data = mysqli_query($dbconn, $query);
$result = mysqli_num_rows($data);
printf("Number of rows %d \n", $result);
if ($result == 1) {
$row = mysqli_fetch_array($data);
$email = $row('login');
$password = $row('senha');
header("location: marcar_consulta_online.html");
} else {
echo "<script>alert('A password e/ou email est達o erradas');</script>";
}
}
else
{
echo "<script>alert('Deve preencher com o seu email e password);</script>";
?>
<?php
}
mysqli_close($dbcon);
?>
$result = mysqli_num_rows($date);
– user60252
this type of error does not deserve an answer, just a comment
– user60252