Php registration logon system simplified version, php login simplified version _ PHP Tutorial

Source: Internet
Author: User
Tags learn php programming register php
Php registration login system simplified version, php login simplified version. Php registration and login system simplified version, php login simplified version login and registration system is the most common daily online operations, I set up a classification step by step to improve the registration and login system, if there is any error, register php to log on to the simplified version of the system, and log on to the simplified version of php.

Logging on to the registration system is the most common operation for daily Internet access. I have set up a classification to improve the registration and logon system step by step. if there is any error, please forgive me.

Language used:Php

Database:Mysql

This implementation function:

1. user registration

2. user logon

Main files:

Complete Code

1. SQL creates the user table, id, username, and password fields in an existing database.

The code is as follows: create table user (id int (10) not null auto_increment, username varchar (30), password varchar (40), primary key (id ));

2 connect. php database configuration file

<? Php $ server = "localhost"; // host $ db_username = ""; // your database username $ db_password = ""; // your database password $ con = mysql_connect ($ server, $ db_username, $ db_password); // link to the database if (! $ Con) {die ("can't connect ". mysql_error (); // if the link fails to output an error} mysql_select_db ('test', $ con); // select the database (my name is test)?>

3 signup.html registry ticket

      
     User registration page          

4 signup. php registration program

<? Php header ("Content-Type: text/html; charset = utf8"); if (! Isset ($ _ POST ['submit ']) {exit ("error execution ");} // determine whether there is a submit operation $ name =$ _ POST ['name']; // Obtain the name $ password in the form using post =$ _ POST ['password']; // post to obtain the password include ('connect. php '); // connect to the database $ q = "insert into user (id, username, password) values (null,' $ name', '$ password ')"; // Insert the SQL $ reslut = mysql_query ($ q, $ con) from the form to the database; // execute SQL if (! $ Reslut) {die ('Error :'. mysql_error (); // if the SQL execution fails to output an error} else {echo "registered successfully"; // The output is successfully registered} mysql_close ($ con ); // Close the database?>

The registration process is complete. The following figure shows the user logon process.

5 login.html login form

      
     Login          

6 login. php login program

<? PHP header ("Content-Type: text/html; charset = utf8"); if (! Isset ($ _ POST ["submit"]) {exit ("misexecuted");} // checks whether the submit operation include ('connect. php '); // link to the database $ name =$ _ POST ['name']; // Obtain the username form value from post $ passowrd =$ _ POST ['password']; // post to obtain the single user password value if ($ name & $ passowrd) {// if neither user name nor password is blank $ SQL = "select * from user where username = '$ name' and password =' $ passowrd '"; // check whether the database has the corresponding username and password SQL $ result = mysql_query ($ SQL); // execute SQL $ rows = mysql_num_rows ($ result ); // returns a value if ($ Rows) {// 0 false 1 true header ("refresh: 01_url1_welcome.html"); // if it succeeds, exit from the welcome.html page;} else {echo "incorrect user name or password "; echo "script" settimeout(function({{w.location.href}'login.html ';}, 1000); script "; // if the error occurs, jump to the logon page 1 second and try again ;}} else {// if the user name or password is empty, echo "the form is not complete"; echo "script" settimeout(function({{{location.href}'login.html ';}, 1000); script "; // skip to the logon page one second after js is used incorrectly and try again.} mysql_close (); // Close the database?>

7. successful logon to welcome.html

      
     Login successful    Welcome

So far, a simple and complete registration and login system has been completed, and the code is very simple without considering the security robustness of the verification, which will be improved later.

I hope this article will help you learn php programming.

Articles you may be interested in:
  • PHP + AJAX for refreshing registration (real-time detection with user names)
  • Solve phpmyadmin #2002 failure to log on to MySQL server
  • Use Php to write the instance code for Email activation verification after registration
  • Implementation of input information validators during php registration
  • The php user registration page uses js for form verification of specific instances
  • A complete example of ThinkPHP user registration logon message
  • PHP + jQuery registration module development details
  • PHP + jQuery registration module improvement (2): mailbox activation
  • WAMPserver configuration method (allow external access, and set phpmyadmin to enter the user name and password for logon)

Login to the registration system is the most common daily online operation. I set up a classification step by step to improve the registration and login system. if there is any error, please...

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.