Home >Backend Development >PHP Tutorial >PHP Login Remember Password Implementation Idea_PHP Tutorial

PHP Login Remember Password Implementation Idea_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:10:501483browse

form page

Copy code The code is as follows:

Username

Password

Remember password



User information
session_start();
function p($arr){
echo "
"; <br>print_r($arr); <br>echo "
";
}
p($_SESSION);
p($_COOKIE);
?>

Login page
Copy code The code is as follows:

< ?php
function p($arr){
echo "
"; <br>print_r($arr); <br>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
Copy code The code is as follows:

session_start();
echo "Close the browser first, then Try visiting form.php, then click Exit and close the browser to try";
p($_SESSION);
p($_COOKIE);
if(empty($_SESSION['username'] )){
if(empty($_COOKIE['username'])){
echo "Please log in first";exit;
}else{
$_SESSION['username'] = $_COOKIE['username'];
}
}
function p($arr){
echo "";
}
?>
2131231231
Modify information
Launch

Launch page
Copy code 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
Copy code The code is as follows:

session_start();
if(empty($_SESSION['username'])){
echo "Please log in first";
} else{
echo "Here is the message";
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327007.htmlTechArticleForm page copy code code is as follows: form action="login.php" method="post" username input type ="text" name="username"br Password input type="text" name="password"br Remember password input...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn