I have this code to compare the email and the password that are in the database, but always gives the data are wrong, not letting in. What's wrong with the code, can you 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);
?>