I am trying to process a form where if a user enters an email that exists in a database they are redirected to the index page but I can't seem to find out why my code isn't working. It doesn't make it to the if statement to check the user.
// Create connection
$conn = mysqli_connect($host, $user, $password, $database, $port);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connection Successful";
$query = "SELECT * FROM FacultyRegistration where email = " . $_POST['email'] ;
$result = mysqli_query($conn, $query) or die ("There was an error:" . mysqli_error($conn));
if (mysqli_num_rows($result) > 0) {
header('Location: index.php');
exit();
}
else{
header('Location: register.php');
exit();
}
$conn->close();
?>