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