I am trying to write code for registration form which have the following fields. Name, Email address, Date of birth, Address etc. If The new entrants name and email address match with the
existing one it should ask for another name and email.
I used the following code.
<?php
$sel = "SELECT `varEmail`, `intStudentId` FROM `tbl_registration` WHERE `varEmail` = '".$emailaddress."' AND `intStudentId` <> '".$Id."' ";
$res = mysql_query($sel);
if(mysql_num_rows($res) >0)
{ ?>
<h3 style="color:#FF0000; text-align:center;">The Email Address and name already exists. Please mention different one.</h3>
<?php
}
else
{
$insertstudent="INSERT INTO `tbl_registration` (
`varFname` ,
`varLname` ,
`varAddress` ,
`varGender` ,
`intDOB` ,
`varEmail`
)
VALUES (
'".$fname."', '".$lname."', '".$address."', '".$gender."', '".$DOB."', '".$emailaddress."'
);";
$insert_res = mysql_query($insertstudent);
}
?>
But it only checks the email duplication. How can i modify my code to check both name and email duplication?
Wich namefield should be checked? fname, lname or both?
for firstname:
for lastname:
for both: