Php enables administrator login

Source: Internet
Author: User
Php enables the administrator login function to open Dreamweaver cs6 and add the following code:


If ($ _ POST [user]) // determines whether to enter the user name

{

$ Name = $ _ POST ["user"]; // Obtain the logon username

$ Pass = $ _ POST ["pass"]; // Obtain the logon password

Require "ch16-1.php"; // reference the configuration file

$ Link = mysql_connect ($ db_host, $ db_user, $ db_pass) or die (mysql_error ());

Mysql_select_db ($ db_name, $ link );

$ SQL = "select * from $ table_user where u_name = '$ name' & u_pass =' $ pass '";

$ Result = mysql_query ($ SQL); // send an SQL request

If (@ mysql_num_rows ($ result )! = 0) // if a qualified user and password are found

{

Setcookie ("name", "$ name", time () + 60*60*24); // Create a COOKIE

Echo" ";

Echo" ";

Echo"";

Echo"

Login successful! Return to the background homepage in 1 second ...... ";

Echo"";

}

Else // if there is no qualified user and password

{

Echo"

Incorrect username or password! ";

}

}

?>

Administrator login

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.