时间:2021-07-01 10:21:17 帮助过:19人阅读
session_start();
if(isset($_SESSION['user']) && $_SESSION['user']===1){
echo 'welcome admin';
}else{
echo "plase login.
Login";
}
请登录--后台管理系统
$link=mysql_connect('localhost','root','root123')or die('连接数据库失败');
mysql_select_db('test',$link)or die('不能选择数据库test');
mysql_query('set names utf8');
$user=$_POST['user'];
$pass=$_POST['pass'];
if($user==''){
echo '请填写用户名';
exit();
}
if($pass==''){
echo '请填写密码';
exit();
}
$sql="select * from user where user='{$user}' and pass='{$pass}'";
echo $sql;
$result=mysql_query($sql);
//var_dump($result);
if($result>0){
$_SESSION['user']='222';
//header("Location: index.php");
echo '';';
print_r($_SESSION);
echo '
echo $_SESSION['user'];
}
?>
if(isset($_SESSION['user']) && $_SESSION['user']===1){