第一步:先在本地写一个登陆页面和一个内容页面(登陆了才能进去)吧。代码大致如下:
下面是login.php,用于请求登陆的,通过post传递参数,如果登陆成功就会注册session。
if (isset($_POST[\'username\'])) {
$username = $_POST[\'username\'];
$password = $_POST[\'password\'];
if ($username == \'admin\' && $password == \'admin\') {
$_SESSION[\'username\'] = $username;
echo \"<a href=\'content.php\'>进入网站</a>\";
} else {
echo \"-1\";
}
}
?>
<html>
<body>
<form action=\"\" method=\"post\">
<input type=\"text\" name=\"username\" />
<input type=\"password\" name=\"password\" />
<input type=\"submit\" name=\"submit\" value=\"submit\" />
</form>
</body>
</html>
本文地址:https://www.stayed.cn/item/9904
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我