php网页登录,为什么验证不通过,登陆不进去,输入正确的账号密码还是提示先登录?帮忙看一下
答案:2 悬赏:0 手机版
解决时间 2021-01-29 09:29
- 提问者网友:杀手的诗
- 2021-01-28 12:21
pass.php<br><?php<br>header("Content-type:text/html;charset=utf-8");<br> session_start() ;<br> require("conn.php");<br> //echo 'test';exit;<br><br> $pass=$_POST["password"];<br> //$username = $_POST['name'];<br> $sql="select * from admin where name='".$_POST["name"]."'and password='".$pass."'";<br> //$sql = "select password,tel from admin where name = '$username'";<br> $result=mysql_query($sql) or die(mysql_error());<br> if(!$result){<br> header("Location:index.php?msg=用户名不存在");<br> exit;<br> }<br> $rs=mysql_fetch_assoc($result);<br><br> if($pass != $rs['password']){<br> header("Location:index.php?msg=密码有误");<br> exit;<br> }<br> //var_dump($rs);echo '--'.$pass;exit;<br> $_SESSION['username'] = $username;<br> $_SESSION['tel'] = $rs['tel'];<br> header("Location:home.php");<br>?><br>登陆页面<br>index.php<br><!doctype html><br><html lang="en" class="no-js"><br><head><br><meta charset="utf-8"><br><meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"><br><meta content="yes" name="apple-mobile-web-app-capable"><br><meta content="black" name="apple-mobile-web-app-status-bar-style"><br><meta name="format-detection" content="telephone=no"><br><meta name="viewport" content="width=device-width, initial-scale=1.0"><br><link rel="stylesheet" href="css/style.css"><br><title>车票预订</title><br><script language="javascript" type="text/javascript" ><br> function check(){<br> if($('username').value == ''){<br> alert('用户名不能为空!');<br> }<br> if($('password').value == ''){<br> alert('手机号不能为空!');<br> } <br> }<br> function $(id){<br> return document.getElementById(id);<br> }<br><br></script><br><br></head><br><br><body><br><div id="index" red'><?php echo @$_GET['msg']?></font></p><br></div><br></div><br></body><br></html><br>数据库<br> id name password <br>1 admin admin <br>2 lily 12345<br>conn.php<br><?php <br>$conn =@mysql_connect("localhost","root","12345");<br> if (!$conn){<br> die("数据库连接失败: " . mysql_error());<br> }<br> mysql_select_db("hr",$conn);<br> mysql_query("set character set 'utf8'");<br> mysql_query("set names 'utf8'");<br>?>
最佳答案
- 五星知识达人网友:廢物販賣機
- 2021-01-28 13:49
判断session前,需要先使用session_start()启用会话
session_start();
if(isset($_SESSION['username'])){
//用户已经登陆
}else{
//用户未登录或登陆超时
}
session_start();
if(isset($_SESSION['username'])){
//用户已经登陆
}else{
//用户未登录或登陆超时
}
全部回答
- 1楼网友:一叶十三刺
- 2021-01-28 14:59
更改你显示器的分辩率!!
1024*768一般是这么多!!!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯