Reputation: 359
I have created a registration page in PHP and MySQL.
How to prevent user from registering again with the following details: "fname,lname,user_name,email,bikeno,mobileno"
.
I tried with the following select statement, but its not working.
$sql="select * from user_registration where fname='".$fname."' and lname='".$lname."' and user_name='".$user_name."' and email='".$email."' and bikeno='".$bikeno."' and mobileno='".$mobileno."'";
What I need is if the user gives any duplicate details in these columns the user is not registered.
Upvotes: 0
Views: 162
Reputation: 386
$sql="select * from user_registration where fname='".$fname."' or lname='".$lname."' or user_name='".$user_name."' or email='".$email."' or bikeno='".$bikeno."' or mobileno='".$mobileno."'";
//After select query check if users exist or not as
$result = $con->query($sql);
if($result->num_rows > 0)
{
//Here Prevent the user registration with the same details
}
else
{
//Here Insert record into the table
}
Upvotes: 1
Reputation: 698
Try this code
$res = mysqli_query($con,"$sql="select * from user_registration where fname='".$fname."' and lname='".$lname."' and user_name='".$user_name."' and email='".$email."' and bikeno='".$bikeno."' and mobileno='".$mobileno."'";
");
if(mysqli_num_rows($res) > 1)
echo "User Already Exist";
else
// run insert query
Upvotes: 1