Saturday 15 September 2012

html - PHP profile update error with mysql_num_rows -


I have a simple PHP page, where you can update your website profile. There are many updateable inputs such as telephone number, MSN access, etc. A specific, email address field is because it is not a register but an updated page, so the user's current email is to be added. There should appear as the value of the field. But I have a problem when the user changes the email to another, it works fine when it is not in use, but when it does not change its email, and makes some more updates, then this will not work. $ email = mysql_real_escape_string ($ _ POST ['email']); If (email to mysql_num_rows ("mysql_query (select email, where e-mail = '$ email'")))) gt; {echo 'e-mail is already in use. ";}

How should I fix these lines, because whenever the user makes some changes other than e-mail, then the same type of operation is executed and fixed By the way, the user receives an error while changing his e-mail to his email again in practice, which returns 1 value to mysql_num_rows ().

Try something like this:

  $ email = mysql_real_escape_string ($ _ POST ['em Ail ']); $ Username = mysql_real_escape_string ($ _ POST [' username ']); // You can get it from session or anywhere you want $ line = mysql_query ("Select * from user where email = '$ Email' "); if (mysql_num_rows ($ line)> gt; {if ($ username! = $ Row [" user name "]) {echo" e-mail is already in use. "; }}   

This may be a user name or other information that identifies the current user.

No comments:

Post a Comment