php Cookie登录源代码如下:
html文件:
<html>
<head>
< >Enter Password</ >
</head>
<body>
<form name=\"forml\" method=\"POST\" action=\"Cookie dPasswordLogin.php\">
<table>
<tr>
<td colspan=\"2\" >
<div align=\"center\"><b>Please Specify the Password</b></div>
</td>
</tr>
<tr>>
<td>
<div align=\"right\">Customer ID</div>
</td>
<td>
<input type=\"text\" name=\"username\">
</td>
</tr>
<tr>
<td>
<div align=\"right\">Password</div>
</td>
<td>
<input type=\"password\" name=\"password\">
</td>
</tr>
<tr>
<td colspan=\"2\">
<center>
<input type=\"submit\" name=\"Submit\" value=\"Login\">
</center>
</td>
</tr>
</table>
</form>
</body>
</html>
php文件如下:
<?php
$now = getdate();
$storetime= $now[\"weekday\"] . \" \" . $now[\"month\"] .\" \" . $now[\"year\"] ;
$storetime.=\" Time : \";
if ($now[\"hours\"] < 10) {
$storetime.= \"0\" . $now[\"hours\"];
} else {
$storetime.= $now[\"hours\"];
}
$storetime.= \":\";
if ($now[\"minutes\"]<10) {
$storetime.= \"0\" . $now[\"minutes\"];
} else {
$storetime.= $now[\"minutes\"];
}
$storetime.= \": \";
if ($now[\"seconds\"] <10) {
$storetime.= \"0\" . $now[\"seconds\"];
} else {
$storetime.= $now[\"seconds\"];
}
if (isset($data)) {
$counter=++$data[l];
setcookie(\"data[0]\",$storetime,time() + (60*60*24));
setcookie(\"data[l]\", $counter,time() + (60*60*24)); setcookie(\"data[2]\",$username,time() + (60*60*24));
echo \"<b><center>Hi \" . $data[2] . \" ! !</center></b><br>\\n\";
echo \"<b><center>Last Login Time :\" .$data[0] . \"</center></b><br>\\n\";
echo \"<b><center>Current Date :\" .$storetime. \"</center></b><br>\\n\";
echo \"<b><center>Page View Count :\" . $data[l]. \"</center></b><br>\\n\";
echo \"<b><center>You have successfully logged in!</center></b>\";
echo (\"<b><contor>You can access this area without entering a password for the next 24 hours!</center></b>\");
} else {
if (isset($username) && isset($password)) {
if ($password==\"superpass\") {
$counter=0;
setcookie(\"data[0]\",$storetime,time() + (60*60*24));
setcookie(\"data[l]\",$counter,time() + (60*60*24));
setcookie(\"data[2]\",$username,time() + (60*60*24));
$url=\"Location: cookieimp.php\";
header($url);
}else{
echo \"<hl><center>INVALID PASSWORD!!!</center></hl>\";
}
}
}
?>
更多cookie学习资料请看这篇文章:http://www.manongjc.com/article/153.html
继续阅读与本文标签相同的文章
上一篇 :
获得云计算支持的六大新兴技术
-
互联网之光大会的黑科技,总有一款惊艳你!
2026-05-14栏目: 教程
-
微信宣布一项新举措,关系到每一个用户,网友一致力挺:干得漂亮!
2026-05-14栏目: 教程
-
微软建议企业客户卸载KB4520062累积更新
2026-05-14栏目: 教程
-
他让我国芯片研究停滞13年,还骗走11亿研发资金,现状如何?
2026-05-14栏目: 教程
-
健乐教学机器人可开展的教学实训内容
2026-05-14栏目: 教程
