What could be the cause of this? I want it to query the database and send the user message if the specified email exists in the database and flag error otherwise
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include 'includes/config.php';
include 'includes/functions.php';
$email = benny($_POST['email']);
$from = "support@Adsware.com";
$subject = "Password Reset";
$msg = "Hello, you have requested to reset your password";
$to = $email;
if (empty($_POST['email'])) {
echo "<script> alert(\"Please Enter your Email Address.\") </script> ";
}else{
$sql = "SELECT * FROM users WHERE email = $email";
}
if (mysqli_query($con, $sql)) {
if(mail($to, $subject, $msg)){
echo "<script> alert(\"An Email with password reset link has been sent to your email inbox. Please Check it\") </script>";
}else{
echo "<script> alert(\"Email does not Exist\") </script>";
}
}else{
echo "<script> alert(\"Error Encountered\") </script>";
}
}
?>
<form name="recover" action="" method="POST" autocomplete="off">
<label>Username</label>
<input type="email" name="email" placeholder="Enter Your Email">
<input class="login-sub" type="submit" name="submit" value="Reset Password">
</form>
<a href="login.php"><button id="Login"> Login </button></a>
But it displays the error:
Warning: mysqli_query(): Empty query in C:\xampp\htdocs\IT\Adsware.comecover.php on line 15