PHP login remember password implementation train of thought _ PHP Tutorial

Source: Internet
Author: User
PHP login remember password implementation ideas. Copy the code on the form page: formactionlogin. phpmethodpost username inputtypetextnameusernamebr password inputtypetextnamepasswordbr remember password input form page

The code is as follows:



User information
Session_start ();
Function p ($ arr ){
Echo"

"; 
print_r($arr);
echo "
";
}
P ($ _ SESSION );
P ($ _ COOKIE );
?>


Logon page

The code is as follows:


Function p ($ arr ){
Echo"

"; 
print_r($arr);
echo "
";
}
Session_start ();
// P ($ _ POST );
$ _ SESSION ['username'] =_ _ POST ['username'];
$ _ SESSION ['password'] =$ _ POST ['password'];
If ($ _ POST ['jizhu']) {
Setcookie ('username', $ _ POST ['username'], time () + 60 );
Setcookie ('password', $ _ POST ['password'], time () + 60 );
}
Header ("location: form. php ");


User information page

The code is as follows:


Session_start ();
Echo "first close the browser, try to access form. php, and then click ";
P ($ _ SESSION );
P ($ _ COOKIE );
If (empty ($ _ SESSION ['username']) {
If (empty ($ _ COOKIE ['username']) {
Echo "log on first"; exit;
} Else {
$ _ SESSION ['username'] = $ _ COOKIE ['username'];
}
}
Function p ($ arr ){
Echo"

"; 
print_r($arr);
echo "
";
}
?>
2131231231
Modify information
Launch


Launch page

The code is as follows:


Session_start ();
Unset ($ _ SESSION ['username']);
Unset ($ _ SESSION ['password']);
Setcookie ('username', '', 0 );
Setcookie ('password', '', 0 );
Header ("location: form. php ");
?>


Modify user information page

The code is as follows:


Session_start ();
If (empty ($ _ SESSION ['username']) {
Echo "log on first ";
} Else {
Echo "Here is information ";
}
?>

The authorization code is as follows: form action = "login. php "method =" post "user name input type =" text "name =" username "br password input type =" text "name =" password "br remember password input...

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.