For the php registration page, check whether the user input meets the requirements without running this step. could you tell me what went wrong? What should I do?

Source: Internet
Author: User
For the php registration page, check whether the user input meets the requirements without running this step. could you tell me what went wrong? PHPcode & lt ;? Php // new user registration function functionregister () {// definition of two variables $ str1 = & quot; & lt; p & gt; user NOTE: & lt; /p & gt; the php registration page does not run the check to check whether the user input meets the requirements. could you tell me what went wrong?
PHP code
  
  Note:

Read the following carefully:

----------------

---- Agreement content ----

----------------

Agree to disagree

"; $ Str2 =" "; // Determine how to deal with the next step based on the message value $ msg = $ _ GET [" message "]; if (! Isset ($ msg) $ msg =$ _ POST ["message"]; if ($ msg = 'new') {echo $ str1; exit ();} elseif ($ msg = 'agree ') {echo $ str2; exit ();} elseif ($ msg = 'Reg ') {// check whether user input meets the requirements $ username =$ _ POST ["username"]; $ password =$ _ POST ["passwd"]; $ repasswd =$ _ POST ["repasswd"]; $ passwda =$ _ POST ["passwdpa"]; $ passwdq =$ _ POST ["passwdq"]; if ($ username = "" | $ password = "" | $ repasswd = "" | $ passwdq = "" | $ passwda = "") {echo "required item cannot be blank! ";} If ($ password! = $ Repasswd) {echo "inconsistent passwords! ";}// Check whether a user with the same name exists in the database $ conn = @ mysql_connect (" localhost "," root ","") or die ("failed to connect to database"); mysql_select_db ("project", $ conn); $ SQL = "SELECT username FROM member WHERE usename = '$ username '"; $ result = mysql_query ($ SQL); if (mysql_fetch_object ($ result) {mysql_close ($ conn); echo "the user name already exists! ";}// INSERT user data INTO the database $ SQL = 'Insert INTO member (username, password, userpassq, userpassa, email, telephone, address) VALUES ('. $ _ POST ['username']. ','. $ _ POST ['passwd']. ','. $ _ POST ['passdp ']. ','. $ _ POST ['passda']. ','. $ _ POST ['email ']. ','. $ _ POST ['tel']. ','. $ _ POST ['add']. ')'; if (mysql_query ($ SQL) {$ sql2 = "SELECT id FROM Member WHERE username = '$ username'"; $ result = mysql_query ($ sql2 ); $ res = mysql_fetch_object ($ result); $ Id = $ res-> id; session_register ($ memberid); $ reuturnpage = "Location: loginscreen. php? Username = '$ username' "; mysql_close ($ conn); header ($ returnpage);} else {mysql_close ($ conn); header (" Location: register. php? Message = ". urlencode (" registration failed! Please try again "); exit ;}} else {$ msg =$ _ GET [" message "]; echo $ msg; exit () ;}// page section?> User registration page

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.