标签:bsp date BMI name isset text reset cti tco
index.php
<html>
<body>
<h1>Login In</h1>
<?php
$user=isset($_COOKIE[‘id‘])?$_COOKIE[‘id‘]:‘‘;
$pwd=isset($_COOKIE[‘password‘])?$_COOKIE[‘password‘]:‘‘;
?>
<form method = "post" action="./base.php">
<table>
<tr>
<td>User id</td>
<td> <input type="text" name="id" value="<?php echo $user;?>"></td>
</tr>
<tr>
<td>Password</td>
<td ><input type="password" name="password" value="<?php echo $pwd;?>"></td>
</tr>
<tr>
<td><input type="submit" value="login"></td>
<td><input type="reset" value="reset"></td>
</tr>
</table>
</form>
</body>
</html>
base.php
<?php
$user=$_POST["id"];
$pwd=$_POST["password"];
if(!empty($_COOKIE[‘id‘])){
setcookie("id",$user,time()+3600);
}else{
setcookie("id",$user,time()+3600);
}
if(!empty($_COOKIE[‘password‘])){
setcookie("password",$user,time()+3600);
}else{
setcookie("password",$user,time()+3600);
}
echo "welcome, ".$_POST["id"]."login success!";
echo "<br/><a href=‘index.php‘>Baack to login</a>";
if(!empty($_COOKIE[‘lastVisit‘])){
echo "your last login time : ".$_COOKIE[‘lastVisit‘];
setcookie("lastVisit",date("Y-m-d H:i:s"),time()+24*3600*30);
}else{
echo "your first login time :";
setcookie("lastVisit",date("Y-m-d H:i:s"),time()+24*3600*30);
}
?>
标签:bsp date BMI name isset text reset cti tco
原文地址:https://www.cnblogs.com/hai-/p/13445310.html