I have a register and login page that is connected to my sql DB. The register takes the values as it should but the login.php gives this error:
Warning: Trying to access array offset on value of type bool in C:\xampp\htdocs\login\login.php on line 22
here is my code:
login.php
<?php
require_once "config.php";
require_once "session.php";
$error='';
if($_SERVER["REQUEST_METHOD"]=="POST"&&isset($_POST['submit'])){
$email=trim($_POST['email']);
$password=trim($_POST['password']);
if(empty($email)){
$error .='<p class="error">please enter email</p>';
}
if(empty($password)){
$error .='<p class="error">please enter password</p>';
}
if(empty($error)){
if($query=$db->prepare("SELECT * FROM users WHERE email=?")){
$query->bind_param('s',$email);
$query->execute();
$row=$query->fetch();
if($row){
if(password_verify($password,$row['password']==false||is_null($row['password']))){
$_SESSION["userid"]=$row['id'];
$_SESSION["user"]=$row;
header("location: welcome.php");
exit;
}else{
$error.='<p class="error">password is wrong</p>';
}
}else{
$error.='<p class="error">email is wrong</p>';
}
}
$query->close();
}
mysqli_close($db);
}
?>
I have tried is_null but that did not seem to work