Jump to content

Ignore current ID when checking current email address


prw

Recommended Posts

Hello - I've come to an issue with something I'm working on and have searched around with no luck.

 

When editing user accounts I want it to not be able to change the e-mail address into existing ones on other rows, but when submitting the form it takes into account that this particular rows email address is the same as the one which was sent via $_POST and throws up the error.

 

The desired behaviour I want is for it to ignore the ID of the row which was posted, but take into account every other row.

 

Here's the code as it stands at the moment:

 

$email = $_POST['email'];
        $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");

} if (mysql_num_rows($checkemail) > 0) {
return $this->error("The e-mail address you provided is already associated with an account.");
}

Link to comment
Share on other sites

  $email = $_POST['email'];
  $checkemail = mysql_query("SELECT email FROM users WHERE email='$email' AND username!='$loggedUsername' LIMIT 1");

  if(mysql_num_rows($checkemail) > 0) {
    return $this->error("The e-mail address you provided is already associated with an account.");
  }

 

Just make sure that you don't include the current user by filtering them out, use something like the above.

Tell me if this works or not buddy :)

 

Regards, PaulRyan.

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.