So I try to do a php logIN system, but I have problem with the $_SESSION, when i put the condition to open the account.php page with user and Password, i don t know why don t let me to login if the user and pass is in the database and is corect
login.php page
<?php if(isset($_POST['login'])){
$user = $_POST['username'];
$PW = $_POST['password'];
$result = $con->query("SELECT * FROM user WHERE Username='$user' AND Password='$PW'");
$row = $result->fetch_array(MYSQLI_BOTH);
session_start();
$_SESSION["userID"] = $row['userdID'];
header('Location: account.php');
}
?>
account.php page
<?php require 'conx.php'; ?>
<?php session_start();
if(isset($_SESSION["userID"])){
} else{
header('Location: login.php');
}
?>
<p>MY ACCOUNT<?php echo $_SESSION["userID"]; ?> </p>
and the DB structure
`userID`, `Name`, `Email`, `Username`, `Password`, `Timestamp`, `Userlevel`, `ProfileImage`, `Bio`