I have made user registration & login system. But i have problems in my form, when new user signup it must provide first name, last name, email, phone and password. After signup if an other user signup with different phone number but same email it also got sign up. So i need to signup those user's who have different phone and email. In simply words i need to remove repetitions. My html code is as follow:
<form action="#" method="post">
<input class="form-control" type="text" placeholder="First Name" required name="fname" >
<input class="form-control" type="text" placeholder="Last Name" required name="lname" >
<input class="form-control" type="text" placeholder="Enter your phone number"
id="phonecheck"name="phone"
<input class="form-control" type="password" placeholder="Enter Password" required name="password" >
<button class="btn btn-primary" type="submit" name="btnreg"><i class="fa fa-check-square"></i> Sign Up</button>
</form>
My php code:
<?php if (isset($_POST['btnreg'])) {
include 'connection.php';
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$password=$_POST['password'];
$sql=mysqli_query($con,"select * from tblusers where phone='".$phone."' AND email='".$email."'");
$numrows=mysqli_num_rows($sql);
if ($numrows==0)
{
$sql="insert into tblusers (f_name,l_name,phone,email,password) values ('$fname','$lname','$phone','$email','$password') ";
$result=mysqli_query($con,$sql);
if ($result==true) {
echo "<script type = \"text/javascript\">
alert(\"Successfully Registered.\");
window.location = (\"login.php\")
</script>";
}
else {
echo "<script type =text/javascript>
alert(Registration Failed. Try Again);
window.location = ('signup.php')
</script>";
}
}
else {
echo "Email & Phone Number Already exists";
}
}
?>