PHP中的重定向问题 [英] Problem with Redirect in PHP

查看:58
本文介绍了PHP中的重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在验证用户登录后重定向网页时遇到了一些问题。我已粘贴下面的代码。我的主体是在代码的最后一行之后。除了重定向之外,一切正常。我不知道我的代码有什么问题


<?php

session_start();

require_once''functions.php '';

$ UserName = $ _POST [''UserName''];

$密码= $ _POST [''密码''];

如果($ _POST){

$ error = login_check($ _ POST);

if(trim($ error)=="")

{

$ accesslevel = accessLevel($ UserName);

?>

<?php

if($ accesslevel ==" admin"){

// echo" this is admin" ;;

$ _SESSION [" userid" ] = login($ _ POST);

header(''Location:adminlogin.php'');

exit();

}

else if($ accesslevel ==" user"){

// echo这是用户;

$ _SESSION [" userid"] =登录($ _ POST);

header(''Location:userlogin.php'');

退出();

}

}

else {

print"错误:$ error" ;

}

}

?>

< BODY>

< FORM id = form1 name = loginform method = post>

< TABLE align = center>

< TBODY>

< TR>

Hi , I am having some problem with redirecting the webpage after authenticating the user login. I have pasted the code below. My main body is after the last line of the code. Everything is working fine except the redirection one. I dont know whats wrong with my code

<?php
session_start();
require_once ''functions.php'';
$UserName = $_POST[''UserName''];
$Password = $_POST[''Password''];
if ($_POST){
$error = login_check($_POST);
if (trim ($error)=="")
{
$accesslevel = accessLevel($UserName);
?>
<?php
if ($accesslevel == "admin"){
//echo "this is admin";
$_SESSION["userid"] = login($_POST);
header(''Location: adminlogin.php'');
exit();
}
else if ($accesslevel == "user") {
//echo "this is user";
$_SESSION["userid"] = login($_POST);
header(''Location: userlogin.php'');
exit();
}
}
else {
print "Error :$error";
}
}
?>
<BODY>
<FORM id=form1 name=loginform method=post>
<TABLE align=center>
<TBODY>
<TR>

推荐答案

UserName =
UserName =


_POST [''UserName''];
_POST[''UserName''];


密码=


这篇关于PHP中的重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆