
<?php
/*
* Created on 2011-7-22
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
session_start();//初始化session
if(isset($_SESSION['Adm'])){
//重定向管理员页面
header("location:admin_brow.php");
//登陆过的话,退出
exit;
}
//获取参数
$username=$_POST['username'];
$password=$_POST['password'];
//检查管理员和用户名密码是否正确
//这里采用直接检查,没有用数据库
if($username=="admin" and $password=="123456"){
//注册session变量,保存当前用户昵称
session_register('Adm');
$Adm=$username;
//登陆成功重定向管理员页面
header("location:admin_brow.php");
}else{
//管理员登陆失败
echo "<table width='100%' align=center><tr><td align=center>";
echo "账号或密码错误,或者不是管理员账号<br>";
echo"<font color=red>管理员登陆失败!</font><br><a href='login.php'>请重试</a>";
echo "<td></tr></table>";
}
?>
管理员登陆成功后页面,可是我感觉这些代码是有错的,请大家给我分析下! /*
* Created on 2011-7-22
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
session_start();//初始化session
if(isset($_SESSION['Adm'])){
//重定向管理员页面
header("location:admin_brow.php");
//登陆过的话,退出
exit;
}
//获取参数
$username=$_POST['username'];
$password=$_POST['password'];
//检查管理员和用户名密码是否正确
//这里采用直接检查,没有用数据库
if($username=="admin" and $password=="123456"){
//注册session变量,保存当前用户昵称
session_register('Adm');
$Adm=$username;
//登陆成功重定向管理员页面
header("location:admin_brow.php");
}else{
//管理员登陆失败
echo "<table width='100%' align=center><tr><td align=center>";
echo "账号或密码错误,或者不是管理员账号<br>";
echo"<font color=red>管理员登陆失败!</font><br><a href='login.php'>请重试</a>";
echo "<td></tr></table>";
}
?>