Php user logon code session and cookie automatic memory _ PHP Tutorial

Source: Internet
Author: User
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 code is as follows:





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"

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.