Hi,
I have a piece of code which checks if an email address is already in the database. However what ever I try I cant get it to prevent a duplicate entry from entering the database.
Is there a piece of code which stops entries into a database if there are duplicates?
PHP Code:
$query = mysql_query("SELECT * FROM users WHERE email = '". $email ."'");
$emailduplicate = null;
if (mysql_num_rows($query) > 0)
{
$emailduplicate = 'Email Address is Already in Use. Please <a href="http://www.website.com/test/activation.php?userid=Y">Retrieve Your Password</a>.';
}
if
($registerPassword === $email) {
$errors['emailalreadyinuse'] = 'You cannot join.';
}
if(!$errors){
$registerPassword = md5($registerPassword);
$query = "INSERT INTO users (usertype, usertypelink, activationcode, firstname, surname, email, password, logo, date_registered) VALUES ('" . $usertype . "', '" . $usertypelink . "', '" . ($activationcode) . "', '" . $firstname . "', '" . $surname . "', '" . mysql_real_escape_string($registerEmail) . "', '". $registerPassword ."', '". $logo ."', NOW())";
$result = mysql_query($query); // remove the or die(mysql_error()) code after you resolve the error
if($result){
$success['register'] = '
Thank you for registering with website.com.<br>
You will soon receive a confirmation email. Please click the confirmation link.<br><br>';
Bookmarks