I have a user login that is not starting the session and therefore users can't login. In page 2 I tried echo $_SESSION['email']; to see if the session variable was being passed and nothing appeared.
I doubled checked phpmyadmin and the format of the database and it's columns is correct as well as the data these forms are looking for.
Edit: all code is in the hs folder. there is NO whitespace before either of the session_start();
Page 1:
<?php
session_start();
include '../hs/connect.php';
$email = mysqli_real_escape_string($con, trim($_POST['email']));
$password = mysqli_real_escape_string($con, $_POST['password']);
// echo $email when i tested these variables they returned the correct values
// echo $password
$sql="SELECT * FROM users WHERE email='$email' and password='$password'";
$result=mysqli_query($con,$sql);
$count=mysqli_num_rows($result);
if ($count==1){
$_SESSION['email'] = $email;
echo '<meta http-equiv="refresh" content="0;url=/hs/nextlogin.php">';
}
else{
echo '<meta http-equiv="refresh" content="0;url=/hs/hs.php">';
}
?>
The page that the above one redirects to (page 2):
<?php
session_start();
if (!isset($_SESSION['email'])) {
die("Please login <a href='../hs/hs.php'>here</a>"); //this keeps appearing even though I entered the correct login data
}
?>