Page 1 of 1

check email - registration script , help

Posted: Sun Nov 24, 2002 5:31 pm
by cooler75
hello people :D
I have a user registration script which allow user to register to become a member. I basically have a complete working script now, however, i would like to add one more check to it.

the original script checks for if the username is exist, if there is username, first name, last name inputs in the field, if it's a valid email address before registering user, however, i need to also check that if the email address has been registered before and i got stuck here...

here is part of my email exist checking script:

Code: Select all

....

//email already exists?
$result = mysql_query("SELECT mgremail FROM mgrs where mgremail = '$mgremail'");
elseif (mysql_num_rows($result) > 1)

    {
print "Your email address has already registered in our database, are you sure you need to
register again?  Please use 'forgot password' to retrieve your information.  Thank you!";
   exit;
    }

...
however, this script doesnt check the whole email database, it only check the first row.

could somebody please point me to the right direction?

thank you :roll:

Posted: Sun Nov 24, 2002 10:30 pm
by oldtimer
I use this for checking if an email address is correct or not. I am sure there are other ways.
<?php
$email_check = explode("@", $email);
$emailhost = $email_check[1];
if (!getmxrr($emailhost, $mxhostsarr))
{
echo "email address is not a valid host";
exit;
}
?>

As far as seeing if that email address was registered before I would change it to > 0. Or change it to >=1. If your num rosw is 0 then you should continue.. It is amazing at how many ways a person can do something. I for example use this to check if a username already exists

// query the database to see if this login is being used.
$query = "select count(*) from users where login = '$login'";
$result = mysql_query( $query );
$count = mysql_result( $result, 0, 0 );
if ( $count > 0 )
{
echo "Sorry but that login name is already being used.<BR>Please go back and select another one.";


} else { the rest of the routine.
}

This is of course after connecting to the database.