This question already has an answer here:
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\cms\users\check_availability.php on line 6
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\cms\users\check_availability.php on line 7
<?php
require_once("includes/config.php");
if(!empty($_POST["email"])) {
$email= $_POST["email"];
$result = mysqli_query("SELECT userEmail FROM users WHERE userEmail='$email'");
$count = mysqli_num_rows($result);
if($count>0)
{
echo "<span style='color:red'> Email already exists .</span>";
echo "<script>$('#submit').prop('disabled',true);</script>";
} else{
echo "<span style='color:green'> Email available for Registration .</span>";
echo "<script>$('#submit').prop('disabled',false);</script>";
}
}
?>
</div>
You are clearly missing $connection
or $link
, the Database connection here
$result = mysqli_query($conn, "SELECT userEmail FROM users WHERE userEmail='$email'");
mysqli_num_rows($result);
You need to create an object of mysqli connection.You have to pass two parameters in mysqli function one is db connection object and second is query.Please refer below link https://www.w3schools.com/php/func_mysqli_query.asp