In select-PHP, check whether the registered email address already exists in the SQL statement. why is it invalid?

Source: Internet
Author: User
# ** The problem is solved. ** Key code: Check whether the email address is repeated & quot; $ user_email $ _ POST [& quot; user_email & quot;]; $ SQL & quot; selectcount (*) fromuserswhereuser_email & #39; $ user_email & #39; & quot; $ resultmysql_query ($ SQL, $ con); $ rowmysql_fetch_row ($ result ); if ($ row [0] & gt; selectmysqlphpsql

The problem is solved.

Key code:
// Check whether the email address is repeated

$ User_email = $ _ POST ["user_email"]; $ SQL = "select count (*) from users where user_email = '$ user_email'"; $ result = mysql_query ($ SQL, $ con); $ row = mysql_fetch_row ($ result); if ($ row [0]> 0) {echo $ row [0]; echo"
The email address has already been registered. Please log in or retrieve the password ";} else {// ---- add a new user -- begin

-------- Problem update -------
Use the following code. when registering, enter an existing email address of the database, and the registration will still be successful.
This is not normal. where is the problem?
After my positioning, it seems that the code "check whether the email address is repeated" has not taken effect. could you please take a look?

// Check whether the email address is repeated $ user_email =$ _ POST ["user_email"]; $ SQL = "select count (*) from users where user_email = '$ user_email '"; if (mysql_query ($ SQL, $ con) = '1') {echo "exist";} else {// ---- add a new user -- begin
     
       
   
   '; Echo "registration successful! ".'

'; Echo "Nice to meet you,". $ _ POST ["user_nickname"].'
'; $ Url ='/login. php'; echo "Click here to log on"; // disconnect the database mysql_close ($ con) ;}// ---- add a new user -- end} else echo"
:( Failed, please modify ~ ";?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.