php管理员登录文件,快速的事情,只有管理员,PHP才能访问文件
我有這個(gè)welcome.php管理員被重定向時(shí),他是通過(guò)身份驗(yàn)證,我有這個(gè)其他hostess.php我希望它只顯示給管理員,我的意思是,沒(méi)有人應(yīng)該有權(quán)訪問(wèn),除非他或她登錄。
welcome.php文件包含這個(gè)小代碼:
我如何插入hostess.php那里?
- log out
Welcome <?php echo $login_session; ?>
登錄頁(yè)面代碼:
include("config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);
$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;
header("location: welcome.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
UserName :
Password :
總結(jié)
以上是生活随笔為你收集整理的php管理员登录文件,快速的事情,只有管理员,PHP才能访问文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php处理heic格式图片,iPhone
- 下一篇: php cookie expires,p