View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Check for duplicate email address as well as username (user registration)

Thread began 10/02/2009 4:01 pm by phil | Last modified 1/16/2010 11:30 am by phil | 7592 views | 23 replies


Check for duplicate email address as well as username (user registration)

Hi all,

This thread might be totally pontless if the extension actually performs this functionality, but I couldnt find a menu to let me check that the registrants email address doesnt already exist as well as username. Is it possible?

Checking for a duplicate email address in the database is fairly essential functionality for me. I never want the same email address registering different accounts.

I modified the code which checks the database for a duplicate username so that it also checks for a duplicate email. It may be of interest to others.

You will need to replace 'u_email' and 'u_username' with your own email/username field name's.

You could easily modify it to check that the person registering doesnt have the same pet, car, street address etc as anyone else already registered too (if you wanted), as well as multiple other checks.


// *** Redirect if username or email exists
if (isset($_POST[$MM_flag])) {
//check username
$loginUsername = $_POST['u_username'];
$LoginRS__query = "SELECT u_username FROM users WHERE u_username='" . $loginUsername . "'";
mysql_select_db($database_watestConn, $watestConn);
$LoginRS=mysql_query($LoginRS__query, $watestConn) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//check email
$loginEmail = $_POST['u_email'];
$LoginRS__query_email = "SELECT u_email FROM users WHERE u_email='" . $loginEmail . "'";
mysql_select_db($database_watestConn, $watestConn);
$LoginRS_email=mysql_query($LoginRS__query_email, $watestConn) or die(mysql_error());
$loginFoundEmail = mysql_num_rows($LoginRS_email);

//if there is a row in the database, the username was found - can not add the requested username
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
}else if($loginFoundEmail){ //if there is a row in the database, the email was found
$MM_qsChar = "?";
//append the email to the redirect page
if (substr_count($MM_dupKeyRedirect_email,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect_email = $MM_dupKeyRedirect_email . $MM_qsChar ."reqemail=".$loginEmail;
header ("Location: $MM_dupKeyRedirect_email");


Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...