这个登陆页面为什么不能回到前一个URL?

alongalong 2004-08-11 10:35:28
<?php require_once('Connections/thw.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}

if (isset($_POST['textfield'])) {
$loginUsername=$_POST['textfield'];
$password=$_POST['textfield2'];
$MM_fldUserAuthorization = "";
MM_redire$ctLoginSuccess = "xz.htm";
$MM_redirectLoginFailed = "dlsb.htm";
$MM_redirecttoReferrer = true;
mysql_select_db($database_thw, $thw);

$LoginRS__query=sprintf("SELECT xm, mm FROM zc WHERE xm='%s' AND mm='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $thw) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;

//register the session variables
session_register("MM_Username");
session_register("MM_UserGroup");

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style2 {font-size: 12}
.style3 {color: #3300FF}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>

<p><span class="style2"><span class="style3">如果您还没有注册,请您先</span>    <a href="zc.php"><span class="style1">注 册</span></a></span></p>
<p> </p>
<p> </p>
<form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="form1" onSubmit="MM_validateForm('textfield','','R');return document.MM_returnValue">
<p>                            <span class="style1">请登录您的     姓 名
<input name="textfield" type="text" maxlength="10">
</span></p>
<p>                                       <span class="style1"> 密 码
<input name="textfield2" type="password" maxlength="10">
</span></p>
<p> </p>
<p>                                                  
<input type="submit" name="Submit" value="提交">
</p>
<p> </p>
<p> </p>
</form>
<p> </p>
</body>
</html>
每次都回到xz.htm,不回到前一URL?
xz.htm在第13行,MM_redire$ctLoginSuccess = "xz.htm";
...全文
520 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
uuq 2004-08-13
大家可能误解人家的意思了。
这样吧
add_member.php 文件
header("location:/member/login.php?returnurl=/add_member.php");
如:/add_member.php是本页的地址。这是绝对路径。也可以用相对路径
login.php 文件

if ($_GET[returnurl] == "") $gourl = "如果不指明,则go这里";
else $gourl = $_GET[returnurl];

。。。。验证

header($gourl);

echo "<script language='javascript'>";
echo "location=\"".$gourl."\";";
echo "</script>";
回复
fzjw 2004-08-13
有必要吗,你点上面的“管理”就有了
回复
alongalong 2004-08-13
想结帖,找不到给分按钮,怎么办?
CSDN是免费的,但免费的也不一定好,别人愿回答,就回答,不愿就不回答,也无可非议
我希望CSDN为我们菜鸟办一个付费的,按问题难度报价,用真钱交易,可能给我们菜鸟更好,更需要的服务。
要求置顶
回复
alongalong 2004-08-11
: xuzuning(唠叨) ( ) 老大;
前一页,是某一受限制页,当没有登陆打开受限制页时,转到此页,但登录后不能自动回到受限制页了?
回复
pfc001 2004-08-11
学习
回复
xuzuning 2004-08-11
再有:
$loginUsername和$password 是哪里来的?
如果是提交的,那么应确认register_globals=on
否则要用$_POST['loginUsername']和$_POST['password']

另外请检查表zc中是否有xm和mm为空的记录

当register_globals=off时,$loginUsername和$password为空
查询串变为:SELECT xm, mm FROM zc WHERE xm='' AND mm=''
此时若表中有xm和mm为空的记录则mysql_num_rows($LoginRS) >= 1
回复
xuzuning 2004-08-11
1、“前一URL”是什么?在哪里得到的?
2、检查
$LoginRS__query=sprintf("SELECT xm, mm FROM zc WHERE xm='%s' AND mm='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
的内容
3、header后应有exit,否则页面后续内容依然会输出
回复
张海霖 2004-08-11
if (isset($_SESSION['PrevUrl']) && true) {
一定不是不会执行到。为什么,你得调试一下。
}
回复
fzjw 2004-08-11
自己写一个登录验证页面,我的就是自己写的,在首页以外的页面登录,在登陆页面中用隐藏域记录页面地址,登录验证中判断是否有url变量,有,则跳转到url,没有,则显示默认页
回复
fzjw 2004-08-11
这个一定是用DW做的页面
回复
alongalong 2004-08-11

session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "Untitled-4.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
这是前一页的代码
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2004-08-11 10:35
社区公告
暂无公告