I am very new in php and mysql programming. I have recently found the tutorial on YouTube to create a login and registration page. I am making some changes in the code to add some more features which are not given in tutorials. But when i execute the code, i am always getting this error "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\reg_log\register.php on line 25
I am actually adding the EMAIL feature, so the user add their email to the database.
Here is my php code:
<?php
if(isset($_POST["submit"])) {
$user=$_POST['user'];
$pass=$_POST['pass'];
$email=$_POST['email'];
$query=mysql_query("SELECT * FROM users WHERE username='$user' email='$email'");
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$sql="INSERT INTO users(username,password,email) VALUES ('$user','$pass','$email')";
$result=mysql_query($sql);
if($result) {
echo "User Account Successfully Created";
} else {
echo "Unable To Create User Account";
}
} else {
echo "That username already exists! Please choose another username";
}
}
?>