I have a php code for a sign up form, it stores the details to a table(temp_members_db), then sends a confirmation code to the email entered. If the code is clicked, the details from temp_members_db is transferred to a new table registered_members, from which login details are checked if a user logs in.
The problem is related to the signup code, how can I avoid duplication of emails and username? My code is:
[php]
<?php include('config.php'); $tbl_name=temp_members_db; $confirm_code=md5(uniqid(rand())); $name=$_POST['name']; $email=$_POST['email']; $password=$_POST['password']; $password_confirm=$_POST['password_confirm']; $sql="INSERT INTO $tbl_name(confirm_code, name, email, password)VALUES('$confirm_code', '$name', '$email', '$password')"; $result=mysql_query($sql); if ($password != $password_confirm) { echo "Password do not match"; } else if ($result) { $to=$email; $subject="Your confirmation link here"; $header="from: Name "; $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://[email protected]/confirmation.php?passkey=$confirm_code"; $sentmail = mail($to,$subject,$message,$header); } else { echo "Email not found"; } if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?>
[/php]
Thanks