Login to your account
Welcome back
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Retrieve and sanitize input
$email = $conn->real_escape_string($_POST['email']);
$password = $conn->real_escape_string($_POST['password']);
// Check if the user exists in the database
$sql = "SELECT * FROM user WHERE emails = '$email'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
if (password_verify($password, $row['passwords'])) {
// Password is correct
$_SESSION['user_email'] = $email;
echo "
Login successful. Welcome, $email!
";
// Redirect to the dashboard or another page
header("Location: index.php");
// exit();
} else {
// Password is incorrect
echo "
Invalid password.
";
}
} else {
// User not found
echo "
No user found with this email.
";
}
$conn->close();
}
?>
Don't have an account?
Create an Account