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.");
}

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

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.