<?php
$con = mysqli_connect('localhost', 'root', '', 'crud_db');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
function signin()
{
$session_start;
if (!empty($_POST['email']))
{
echo "not empty";
$query = "SELECT * FROM 'employee' where email= '$_POST ['email']' AND password= '$_POST ['pwd']'";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);
if (!empty($row['email']) AND !empty($row['password'])) {
echo "successfully login";
} else {
echo "login fail";
}
}
}
if (isset($_POST['submit']))
{
signin();
}
?>
I am new in php, and i am trying to create a simple login page here is my php code,a simple login php code. when i try to run the code i get an error Notice: Undefined variable: con in C:\xampp\htdocs\CRUD\login.php on line 14 i already defined the variable $con in first line ,then why i am getting this error.
Second - when i try to run the sinin function block i get an error Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\CRUD\login.php on line 15 what does that mean, and how can i solve this.