Jump to content

check already registered query


fife

Recommended Posts

Hi.  I have wrote a simple login script.  Works perfectly.  Now as my users can only register one email address at the minute if you register two the same you get the default sql error pop up.  I want my own error so at the beginning of my script i wrote the following code. however.  It does not seem to be running.  It does not create an error but still allows duplicate emails in the database.  can anyone see the error of my ways?

<?php session_start();
if(isset($_POST['create'])){    
//script for checking if the email account already exists
$qCheckEmail = "SELECT * FROM members WHERE email='".$_POST['email']."'";
$rCheckEmail = mysql_query($qCheckEmail);
$Email = mysql_fetch_array($rCheckEmail);

if($_POST['email'] == $Email['email']) 
{$emailDup = "This email account has already been registered";}
else
{ 
//Process data for validation    
$forename	= 	trim($_POST['forename']);    
$surname	= 	trim($_POST['surname']);    
$email      = 	trim($_POST['email']);        
$password   = 	trim($_POST['password']);     
$gender     = 	trim($_POST['gender']);
$birthday	= 	$_POST['birthday'];
$creationdate = $_POST['creationdate'];
$validationID = $_POST['validationID'];
$accesslevel = 	trim($_POST['accesslevel']);
$accountType =  trim($_POST['accountType']);
// then the rest of the login script here

Link to comment
Share on other sites

Try something like...

 

...
$qCheckEmail = "SELECT * FROM members WHERE email='".$_POST['email']."'";
$rCheckEmail = mysql_query($qCheckEmail);
if(mysql_num_rows($rCheckEmail)>=1){
// already at least one entry, so it's already registered, tell 'em about it!
}
else
{
// no entries, so carry on with reg...
}
...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.