将下面代码放在主页面(index.php)最上端 (html的前面)
<?php
session_start();
$check = "hello";
if(isset($_POST['name'])&& isset($_POST['pass'])){
if(strlen($_POST['name']) < 1 && strlen($_POST['pass']<1)){
$failure = "Enter Username & Password.";
}
else{
if($check==$_POST['pass']){
$_SESSION["pass"]=$_POST["pass"];
$_SESSION["name"]=$_POST["name"];
header("Location: home.php?");
return;
}
else{
echo("Incorrect Password !");
}
}
}
在 实际真实页面 访问页面(home.php)也增加这么一段代码
<?php
session_start();
if($_SESSION["pass"]){
unset($_SESSION["pass"]);
}
else{
header('Location: index.php');
exit;
}
![支付宝 支付宝打赏](https://code.beiduoye.cn/usr/themes/bdy/images/zfb.jpg)
![微信 微信打赏](https://code.beiduoye.cn/usr/themes/bdy/images/wx.jpg)
暂无评论