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

PHP Login Remember Password Implementation Idea_PHP Tutorial

WBOY
Release: 2016-07-21 15:10:50
Original
1482 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template