Php user logon code session and cookie automatic memory. When a user logs on, there are many types of users with the same basic as my instance log on to the specified page. this is not safe if the user knows your address and does not need to log on, instance 2 uses many of the most basic user logon methods like my instance to log on to the specified page. this is not safe if the user knows your address and does not need to log on, instance 2 uses session verification, which is also commonly used on the operation page. However, you cannot remember to log on next time, instance 3 uses session and cookie to log on at the same time and can automatically record the next automatic login function.
Let's take a look at the simplest example.
The following is a simple login.htm content.
The login. php content is as follows:
The code is as follows: |
|
Error_reporting (0 ); $ Mysql_servername = "localhost"; // host address $ Mysql_username = "root"; // database username $ Mysql_password = ""; // database password $ Mysql_database = "peng"; // Database Mysql_connect ($ mysql_servername, $ mysql_username, $ mysql_password ); Mysql_select_db ($ mysql_database ); $ Name = $ _ POST ['name']; $ Passowrd =$ _ POST ['password']; If ($ name & $ passowrd ){ $ SQL = "SELECT * FROM liuyanban WHERE name = '$ name' and password =' $ passowrd '"; $ Res = mysql_query ($ SQL ); $ Rows = mysql_num_rows ($ res ); If ($ rows ){ Header ("refresh: 0w.urlw.a.htm"); // jump to the page, pay attention to the path Exit; } Echo" |