Registration Verification failed-php Tutorial

Source: Internet
Author: User
Registration Verification failed
 Query ($ SQL); if ($ result & $ row = $ result-> fetch_assoc () {if ($ name = $ row ["name"]) {echo 'script '; echo "alert ('User already exists');"; echo "too many locationparameters 'enroll.html '"; echo "script"; exit ;} elseif ($ mail = $ row ["mail"]) {echo 'script '; echo "alert ('This mailbox is used ');"; echo "window.location='enroll.html '"; echo "script"; exit;} else {$ SQL = "insert into user (name, represent, pwd, mail, time) value ('{$ name}', 0, '{$ pwd }',' {$ Mail} ', now () "; $ result = $ db-> query ($ SQL); if ($ result & $ db-> affected_rows> 0) {$ SQL = "select * from user where name = '{$ name}'"; $ result = $ db-> query ($ SQL ); if ($ result & $ row = $ result-> fetch_assoc () {$ uid = $ row ['uid'] ;}}$ result-> free_result; $ db-> close; $ SQL = "insert into userphoto (uid, name, type, url, size, time) value('{}uid}', 'Steve', '.png ','. /img/userphoto/steve.png ', '6. 24kb ', now () "; $ result = $ db-> que Ry ($ SQL); if ($ result & $ db-> affected_rows> 0) {echo 'script '; echo "alert ('registered successfully ');"; echo "window. location = 'index. php '"; echo" script "; exit;} else {echo 'script'; echo" alert ('registration failed ');"; echo "window.location='enroll.html '"; echo "script"; exit ;}}$ result-> free_result; $ db-> close;} else {echo 'script'; echo "alert ('inconsistent passwords, please re-enter ');"; echo "too many locationparameters 'enroll.html'"; echo "script"; Exit ;}} else {echo 'script '; echo "alert ('No agreement agreed, registration failed');"; echo "cannot exceed location+'enroll.html '"; echo "script"; exit;} $ result-> free_result; $ db-> close;?>



The user already exists. this verification fails. every time you register the same user name, it is successful. how can you change it?


Reply to discussion (solution)

$ SQL = "select * from user ";???
Do you know the execution result of this SQL statement?
It will return all records in the user table, and you only retrieve the first record $ row = $ result-> fetch_assoc ()

$ Db-> close;
$ SQL = "insert into userphoto (uid, name, type, url, size, time) value('{iduid}', 'Steve', '.png ','. /img/userphoto/steve.png ', '6. 24kb ', now ())";

Didn't you close the db before?

$ SQL = "select * from user ";???
Do you know the execution result of this SQL statement?
It will return all records in the user table, and you only retrieve the first record $ row = $ result-> fetch_assoc ()



3q, I understand

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.