when i load my login page i see those errors:
Warning: Undefined array key "email" in C:\xampp\htdocs\alfarabi_website\login\index.php on line 8
Warning: Undefined variable $error in C:\xampp\htdocs\alfarabi_website\login\index.php on line 28
Warning: Undefined variable $success in C:\xampp\htdocs\alfarabi_website\login\index.php on line 29
and when i try to login i see another error instead of the previous one :
Trying to access array offset on value of type bool
tbh i searched over the internet but i didnt understand what is the error and how to fix it, i am new with php and sql .
here is my code :
<?php
#DB connect
$bdd = new PDO('mysql:host=localhost;dbname=alfarabi_website','root','');
#Select db
$req = $bdd -> prepare('SELECT * FROM users WHERE email = :email ');
$req -> execute(array(':email'=>$_POST['email']));
$donnees = $req -> fetch();
session_start();
if (isset($_POST['submit'])) {
// code...
if ($_POST['email']==$donnees['email']) {
// code...
$error = "";
$success = "welcome";
header("location: ../indexAcc.php");
}
else {
// code...
$error = "invalid";
$success = "";
}
}
echo $error;
echo $success;
?>