Jump to content

Email Validation


PRodgers4284

Recommended Posts

I need some help with an edit form i have on my uni project, the form allows users to edit their user account once they are logged into the system. My problem is that is the function i am calling to check the email when the users is editing the account checks all the records in the database. The problem with the code is that i need it to look up the database to check that the email does not already exist but not look up the email that the user already has if that makes sense. Im using $_SESSION["username"] which gets the user account details of the user that is logged in and populates the edit form with the information. Can anyone please help me with this, im really stuck with it.

 

my code is

 

function emailTaken($email){
   global $conn;
   if(!get_magic_quotes_gpc()){
      $email = addslashes($email);
   }
   $q = "select username from users where email = '$email'";
   $result = mysql_query($q,$conn);
   return (mysql_numrows($result) > 0);
}

 

The function is called:

 

if(emailTaken($email,$conn))
{
    $error_stat = 1;
    $email_message = '*Email is taken please choose another one*';
}

 

Phil

Link to comment
https://forums.phpfreaks.com/topic/90509-email-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.