Warning: Trying to access array offset on value of type null
PHP:
<?php
$host="localhost";
$user="root";
$password="";
$db="bpms2db";
session_start();
$data=mysqli_connect($host,$user,$password,$db);
if($data===false)
{
die("connection error");
}
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$email=$_POST["email"];
$password=$_POST["password"];
$sql="select * from login where Email ='".$email."' AND password='".$password."' ";
$result=mysqli_query($data,$sql);
$row=mysqli_fetch_array($result);
$data->close();
if($row["usertype"]=="user")
{
$_SESSION["email"]=$email;
header("location:dashboarduser.php");
}
elseif($row["usertype"]=="admin")
{
$_SESSION["email"]=$email;
header("location:admin/index.php");
}
else
{
echo "<script>alert('email or password incorrect');</script>";
}
}