prw Posted February 19, 2011 Share Posted February 19, 2011 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."); } Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted February 19, 2011 Share Posted February 19, 2011 $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. Quote Link to comment Share on other sites More sharing options...
prw Posted February 19, 2011 Author Share Posted February 19, 2011 Ah perfect, I never thought of doing it like that. This is what I used instead: $checkemail = mysql_query("SELECT email FROM users WHERE email='$email' AND id!='$id' LIMIT 1"); Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.