Php user registration

Source: Internet
Author: User
This article describes how to check and store user registration information in php. The Code is as follows: query (setnamesgb2312); if (empty ($ conn )) {die (Database Connection Failed);} $ UserName $ _ POST [username]; $ pwd $ _ POST [password]; $ email $ _ POST [email]; $ sex $ _ POST [sex]; $ timetime (); $ codestrtolowe

This article describes how to check and store user registration information in php. The Code is as follows: query (set names gb2312); if (empty ($ conn )) {die (Database Connection Failed) ;}$ UserName =$ _ POST [username]; $ pwd =$ _ POST [password]; $ email =$ _ POST [email]; $ sex = $ _ POST [sex]; $ time = time (); $ code = strtolowe

This article introduces an example of how to check and store user registration information in php. The Code is as follows:

Query ('set names gb2312 '); if (empty ($ conn) {die ("database connection failed");} $ UserName = $ _ POST ['username']; $ pwd =$ _ POST ['Password']; $ email =$ _ POST ['email ']; $ sex =$ _ POST ['sex']; $ time = time (); $ code = strtolower ($ _ POST ["code"]); $ str = "select * from users where username = '". $ username. "'"; $ result1 = $ conn-> query ($ str); $ row = $ result1-> fetch_row (); if ($ row) {$ temp = "already registered this name. Please select another name! "; Echo $ temp; echo" back ";} else {if ($ _ SESSION ['sname'] = $ code) {echo $ temp =" authentication code successful "; $ SQL = "INSERT INTO users VALUES ('$ username',' $ password', '$ email', '$ sex',' $ Time ')"; $ result = $ conn-> query ($ SQL); if ($ result = true) {$ _ SESSION ['mail'] = "registration successful, please log in "; echo "";} else {echo "registration failed ". mysql_error () ;}} else {echo "Incorrect verification code" ;}}?>

The above code receives parameters from the registration page, including the user name, password, email address, gender, and verification code. Then, check whether the registration has been completed. Otherwise, write the registration information to the database. Very simple, especially suitable for reference by new friends.

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.