PHP login page information prompt function example, php example

Source: Internet
Author: User
Tags php example

PHP login page information prompt function example, php example

This example describes the logon page information prompt function implemented by PHP. We will share this with you for your reference. The details are as follows:

Login. php:

<! DOCTYPE html> 

Check_login.php:

<? Phpheader ("Content-type: text/html; charset = UTF-8"); session_start (); // initialize the session variable $ username = $ _ POST ['name']; // user name for receiving form submission $ password = md5 ($ _ POST ['pwd']); // password class chkinput for receiving form submission // definition class {var $ name; var $ pwd; function chkinput ($ x, $ y) // define a method {$ this-> name = $ x; // pass the Administrator name to the Class Object $ this-> name $ this-> pwd = $ y; // send the administrator password to the Class Object $ this-> pwd} function checkinput () {include ("conn. php "); // connect to the database file $ SQL = mysql_query (" sel Ect username, password from admin where username = '". $ this-> name. "'and password = '". $ this-> pwd. "'", $ conn); $ info = mysql_fetch_array ($ SQL); // retrieve the Administrator name and password if ($ info = false) // If the Administrator name or password is incorrect, the prompt {header ("location: login. php? Error = 1 "); exit;} else // If the Administrator name or password is correct, go directly to the interface {header (" location: login. php? Error = 2 "); $ _ SESSION ['admin _ name'] = $ info ['username']; // Save the Administrator name to the $ _ SESSION [admin_name] variable $ _ SESSION ['pwd'] = $ info ['Password']; /// Save the Administrator name to the $ _ SESSION [pwd] variable }}$ obj = new chkinput (trim ($ username), trim ($ password )); // create an object $ obj-> checkinput (); // call class?>

Conn. php:

<? Phpheader ("Content-type: text/html; charset = UTF-8"); $ conn = mysql_connect ("localhost", "root", "111111"); if (! $ Conn) {die ("failed to connect to the Database ". mysql_error ();} mysql_select_db ("design") or die ("database selection failed ". mysql_error (); mysql_query ("set names 'uft8'");?>

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.