2017-02-27 56 views
0

具有已经与下面的脚本做了一个问题:事件后成功的登录PHP

if ($getUserType == "Admin") { 
    header("Location: overall_lascruses_users_list.php"); 
    exit(); 
} elseif ($getUserType == "LCLEmployee") { 
    header("Location: overall_lascruses_users_list.php"); 
    exit(); 
} elseif ($getUserType == "Site_Admin") { 
    header("Location: initial_admin_manage.php?id='.$_SESSION['LasCrusesUserID'].'"); 
    exit(); 
} elseif ($getUserType == "Site_Manager" || $getUserType == "Site_User") { 
    header("Location: Control_Panel_list.php"); 
    exit(); 
} 

这是如何工作如下:

在用户登录之后,拾起用户角色,然后 根据其角色重定向到不同的屏幕。

脚本工作正常,直到它加入了以下部分:

header("Location: initial_admin_manage.php?id='.$_SESSION['LasCrusesUserID'].'"); 

这里有什么问题?

注:$_SESSION["LasCrusesLocal_UserID"] = $data["lasCrusesUserID"];

注:

。从我知道其他Q/A如何工作的那一刻起,这不可能是重复的,但仍然无助于我解决问题。

。这里的问题在于调试级别,完全错过了错误。

。花了6个小时试图找出错误之后,决定向社区寻求帮助,找出究竟错在哪里,只是为了理智。

。总而言之,这是独一无二的,我感谢那些帮助我马上修复它的人。 只是再一次证明这个社会仍然能正常为那些有需要的工作时间

+0

为什么把会话值放在url中?为什么不只是阅读会议?可能是一个主要的安全问题 – nogad

+3

而不是''Location:initial_admin_manage.php?id ='。$ _ SESSION ['LasCrusesUserID']。'“',使用''Location:initial_admin_manage.php?id =”。$ _ SESSION ['' LasCrusesUserID']'你有一个引号混淆! – castis

+4

[PHP中单引号和双引号字符串有什么区别?]可能的重复(http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and -double-quoted-strings-in-php) – castis

回答

0

真正的问题本:

header("Location: initial_admin_manage.php?id='.$_SESSION['LasCrusesUserID'].'"); 

应该是这样的:

header("Location: initial_admin_manage.php?id=".$_SESSION['LasCrusesUserID']); 

SEEE单,phph中的双引号它们不是相同的

你可以把一个var放在双引号内,它将被视为h是var本身,但不是在单引号(在大多数情况下,无论如何,取决于你的配置)。

+0

查看链接castis在上面关于引用的评论中发布的链接。 –