session_start();
if (isset($_POST['username'] , $_POST['password'])) {
$extractabout = $db->prepare("SELECT * FROM user WHERE username = :username && password = :password");
$extractabout->execute([
'username' => $_POST['username'],
'password' => $_POST['password']
]);
$infos = $extractabout->rowCount() ? $extractabout : [] ;
foreach ($infos as $info) {
if(!empty($info['username']) && !empty($info['password']) && !empty($info['id']) && !empty('role')) {
$_SESSION['username'] == $info['username'];
$_SESSION['password'] == $info['password'];
}
}
if(isset($_SESSION['username'], $_SESSION['password'], $_SESSION['user_id'], $_SESSION['role'])) {
header("Location: test.php");
}
}
?>
I have an error when I give $_SESSION['username'] the value of $info['username'] called :
Undefined index: username
Undifined index: password
==is different from=. Remember toexit()afterheader("Location: $url");call