I got an error while running this code Help me please To solve this problem thank you very much.
Notice: Undefined variable: conn in E:\xampp\htdocs\MyDataSet\loginApi.php on line 14 Warning: mysqli_query() expects parameter 1 to be mysql. null given in E:\xampp\htdocs\MyDataSet\loginApi.php on line 14.
<?php
require('conn.php');
/*include connection fiele*/
header("Content-Type:Application/json");
header('Acess-Control-Allow-Origin:*');
header('Access-Control-Allow-Methodes:GET');
header('Access-Control-Allow-Heders:Access-Control-Allow-Heders,Access-Control-Allow-
Methodes,Content-Type,Authorization,X-Requested-With');
/*header information*/
function login_function($mail,$pass)
{
$query = "SELECT*FROM user WHERE email='$mail' AND password='$pass'";
$result=(mysqli_query($conn,$query));
if (mysqli_num_rows($result)>0)
{
$json['status']=200;
$json['message']='Login Successful';
echo json_encode($json);
}else{
$json['status']=400;
$json['message']='Wrong email or password';
echo json_encode($json);
}
}
if (isset($_GET['mail'],$_GET['pass']))
{
$mail=$_GET['mail'];
$pass=$_GET['pass'];
if (!empty($mail)&& !empty($pass))
{
login_function($mail,$pass);
}else{
$json['status']=100;
$json['message']='You must fill both fields';
echo json_encode($json);
}
}
?>