PHP sign-in System simplified version, PHP login simplified version
Login registration system is the most common daily access to the operation, I set up a classification of the step-by-step Perfect Registration Login system, if wrong, please forgive me.
Language used:php
Database:mysql
This implementation function:
1. User Registration
2. User Login
Main documents:
Full code
1 SQL creates a user table in an existing database, Id,username,password three fields
Copy the code as follows: CREATE TABLE user (id int () NOT null auto_increment,username varchar (), password varchar (40), Primary key (ID));
2 connect.php Database configuration file
<?php $server = "localhost";//Host $db _username= "";//Your database user name $db _password= "";//Your database password $con = Mysql_connect ($server, $db _username, $db _password);//LINK Database if (! $con) {die ("can ' t connect". Mysql_error ()) ;//If the link fails output error } mysql_select_db (' Test ', $con);//Select Database (mine is test)?>
3 signup.html Registration Form
User Registration page
4 signup.php Registration procedure
<?php Header ("content-type:text/html; Charset=utf8 "); if (!isset ($_post[' submit ')) { exit ("Error Execution"); } Determine if there is a submit operation $name =$_post[' name '];//post get the name of the form $password =$_post[' password '];// Post gets the password include (' connect.php ') in the form,//link database $q = "INSERT into user (Id,username,password) VALUES (NULL, ' $name ', ' $password ');//SQL $reslut =mysql_query ($q, $con) to insert the value of the form into the database ;//Execute SQL if (! $reslut) {die (' Error: '. Mysql_error ());//If the SQL execution fails output error }else{ echo "registered successfully";//Successful output registration succeeded } mysql_close ($con);//Shut down the database? >
The registration process is complete, the following is the user login
5 login.html Login Form
Landing
6 login.php Login Program
<? PHP Header ("content-type:text/html; Charset=utf8 "); if (!isset ($_post["submit"])) { exit ("Error Execution"); } Detects if there is a submit operation include (' connect.php ');//LINK database $name = $_post[' name '];//post get user name form value $PASSOWRD = $_ post[' password '];//post get user password single value if ($name && $passowrd) {//if user name and password are not empty $sql = "SELECT * from user where Username = ' $name ' and password= ' $passowrd ' ";//detect if the database has a 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:0;url= Welcome.html ");//If successful jump to welcome.html page exit; } else{ echo "User name or password error"; echo " ";//if the error using JS 1 seconds after the jump to the login page to retry;} } else{//if the user name or password is empty echo "form fill incomplete"; echo " "; If the error using JS 1 seconds after the jump to the login page retry; } Mysql_close ();//Close Database?>
7 welcome.html Login Success Jump page
Landing success Welcome to visit
At this point a simple complete registration login system is completed, the code is very simple does not consider verifying the robustness of security, after the improvement.
I hope this article will help you learn PHP programming.
Articles you may be interested in:
- Php+ajax for no flush registration (real-time detection with username)
- Resolve phpMyAdmin #2002 cannot log on to MySQL server
- Use PHP to write an instance code for email activation verification after registration
- The implementation of the input information validator when PHP is registered
- PHP user registration page using JS to form validation specific instances
- thinkphp User Registration Login Message Complete Example
- Php+jquery Registration Module Development detailed
- Improvement of Php+jquery Registration Module (II): Mailbox activation
- Wampserver Configuration method (allow external access, phpMyAdmin set to enter user name password to log in, etc.)
http://www.bkjia.com/PHPjc/1108616.html www.bkjia.com true http://www.bkjia.com/PHPjc/1108616.html techarticle PHP Registration System simplified version, PHP login Simplified Login Registration system is the most common daily Internet operation, I set up a classification step by step Perfect registration login system, if wrong, please ...