PHP中的重定向问题 [英] Problem with Redirect in 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屋!