
在跳转到登录页面前要将访客访问的页面的url作为参数传递过去,登录验证后,授予访问权限之后跳转到该url指定的页面。
比如登录前的url为:openphp.html 当访客访问时,点击无权限,跳转到登录页面的地址就为login.php?url=openphp.html,这样在登录时就可以用GET方式获取该参数 openphp.html,登录验证成功后跳转到openphp.html 这个页面就可以了。
PHP
PHP,一个嵌套的缩写名称,是英文超级文本预处理语言(PHP:Hypertext Preprocessor)的缩写。
提交后跳转不能实现你要的功能,
需要用到ajax。
给你个简单的例子:
test.html:
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>表单所在页面</title>
<style>
#msg{color:red}
</style>
</head>
<body>
<form>
<p>用户名:<input type="text" id="user"></p>
<p>密码:<input type="password" id="psd"></p>
<p><input type="button" value="提交" id="submit"/></p>
<p id="msg"></p>
</form>
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$("#submit").click(function(){
var data={
'user':$("#user").val(),
'psd':$("#psd").val(),
}
$.post("test.php",data,function(d){
$("#msg").text(d)
})
})
</script>
</body>
</html>
test.php:
<?php$user=$_POST['user']
$psd=$_POST['psd']
if(!$user||!$psd){exit("用户名或密码不能为空")}
//链接数据库查询
/*
...............
*/
if(true){exit("登录成功")}else{exit("登录失败")}
?>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)