Php login code _ PHP Tutorial

Source: Internet
Author: User
Php login code. Php login code is a complete php login code instance. from the database to the html and php programs, the entire process is written step by step, it is a very good entry-level php login code. this is a complete php login code instance. He wrote the entire process from the database to the html and php programs step by step, it is a very good entry-level php login code.

Php logon code
This is a complete php login code instance. He wrote the entire process step by step from the database tutorial to the html and php programs. it is a very good entry-level login php code.
*/

Session_start ();

/* Get post */
If (! Function_exists ("getpost") {function getpost () {if (count ($ _ post) {foreach ($ _ post as $ key => $ value) {global $ {$ key };$ {$ key }=$ value ;}}}}

/* Get */
If (! Function_exists ("getget") {function getget () {if (count ($ _ get) {foreach ($ _ get as $ key => $ value) {global $ {$ key };$ $ key = ($ value );}}}}

/* SQL escape string */
If (! Function_exists ("escapeit ")){
Function escapeit ($ text ){
If (get_magic_quotes_gpc () $ text = strips tutorial lashes ($ text );
If (! Is_numeric ($ text) $ text = mysql tutorial _ real_escape_string ($ text );
Return $ text;
}}

Getpost (); // Get post data


// Login

$ Rs = $ db-> query ("select * from 'backend _ user' where binary 'login' = '". escapeit ($ login ). "'and binary 'password' = '". md5 ($ password ). "'");

If (mysql_num_rows ($ rs)> 0 ){
$ Row = $ db-> fetch_array ($ rs );
$ _ Session ["smartinfo_sysid"] = $ row ["user_id"];
$ _ Session ["smartinfo_syslogin"] = $ row ["login"];
$ Db-> query ("update 'backend _ user' set 'Last _ logon' = '". date ("y-m-d h: I: s "). "'where' ID' = '". $ row ["id"]. "'");
Header ("location: index2.php ");
} Else {
Header ("location: index. php? Status = fail ");
}

// Functions used

?>
Html code






Control panel





Database

--
-- Table structure 'backend _ user'
--

Create table if not exists 'backend _ user '(
'User _ id' int (11) not null auto_increment,
'Group _ id' int (11) not null default '0 ',
'Login' varchar (255) not null default '',
'Password' varchar (255) not null default '',
'Last _ logon 'datetime not null default' 0000-00-00 00:00:00 ',
Primary key ('User _ id ')
) Engine = myisam default charset = utf8 auto_increment = 2;

--
-- Export the data 'backend _ user' in the table'
--

Insert into 'backend _ user' ('User _ id', 'group _ id', 'login', 'password', 'Last _ logon') values
(1, 0, 'admin', 'e10adc3949ba59abbe56e057f20f883e ', '2017-00-00 00:00:00 ');

...

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.