I am trying to redirect a login page using PHP to the profile.php page. I have tested that the code pulls out the information form the database using the sessions. Everything works fine up until the final If statement. It isn't giving me any errors but it comes back blank and doesn't move away from the login.php file( where the script is running).
session_start();
//print_r($_POST);
if(isset($_POST['email'], $_POST['password'])){
require 'php_includes/db_connect.php';
$query = $dtb->prepare("SELECT * FROM users WHERE email=:email AND password=:password");
//$query->bindParam('ss', $_POST['email'], $_POST['password']);
$query->bindParam(':email', $_POST['email'],PDO::PARAM_STR);
$query->bindParam(':password', $_POST['password'],PDO::PARAM_STR);
$query->execute();
//die('Connection error, because: '.$query->errorInfo());
//echo 'hi';
//$query->close();
if($row = $query->fetch()){
echo 'hi';
$_SESSION['email'] = $row['email'];
header("location: profile.php");
}
}