This is my login code
global $connection;
if (isset($_POST['user_login'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$password= md5($password);
$login = mysqli_query($connection, "SELECT * FROM user WHERE email ='{$email}' AND password = '{$password}' ");
if(!$login) {
die("QUERY FAILED" . mysqli_error($connection));
}
if(!$login || mysqli_num_rows($login) == 0) {
echo "<div class='alert alert-danger' role='alert'> <strong>Your Username or Password is invalid!</strong></div>";
} else {
$_SESSION['user_id'] = $user_id;
$_SESSION['email'] = $email;
$_SESSION['username'] = $username;
header('Location: index.php');
}
}
I used the print_r function to display all the sessions but only the session email is getting declared. Why isn't the user_id and username not getting declared? What did I do wrong?