请帮我登录

时间:2015-11-27 05:54:14

标签: php mysql

我在登录页面遇到一些问题 当我第一次在浏览器中登录时,它将我重定向到登录页面, 之后,如果我使用相同的凭据登录其工作正常

这是我的代码请给我一个解决方案

session_start();

if ($dett['sub_opt'] == 1) {
    $sct = $obj_db->fetchRow("select * from " . TABLE_UPGRADE_SCHOOLS . " where sid='" . $scid . "' ");
    if ($sct['plan_valid_status'] == 0) {
        $a = 1;
    } else {
        $a = $sct['plan_valid_status'];
    }
    $tp = date("Y-m-d H:i:s", strtotime($dett['sub_date'] . " +" . $a . " month"));
    if (date("Y-m-d H:i:s") <= $tp) {
        $school = $obj_db->fetchRow("SELECT * FROM " . TABLE_SCHOOLS . " WHERE id='" . $scid . "'");
        if ($school['school'] == '0') {
            redirect_page($_SESSION['school'] . "/index?p=config&d=dash");
        } else {
            redirect_page($_SESSION['school'] . "/index");
        }
    } else {

        //session_destroy();
        redirect_page($_SESSION['school'] . "/index?p=upgrade");
    }
} else {
    redirect_page("index");
}

2 个答案:

答案 0 :(得分:0)

我觉得$ dett ['sub_opt']不是1所以redirect_page(“index”);

if ($dett['sub_opt'] == 1)
{
//your code
}
else
{
    redirect_page("index");
}

添加更多代码,以便我们知道变量的值。

答案 1 :(得分:0)

听起来好像$ dett ['sub_opt']被设置为低于你的脚本所以它不是第一次是1并且根据Rinku的答案不能通过 if ($dett['sub_opt'] == 1) {并且它不是1,一旦提交一次,它将只变为1。尝试echo "DSO: " . $dett['sub_opt'];进行调试并检查其值。尝试在脚本中的各个点添加它。

也不确定你在哪里设置会话变量 - 你没有更多用于使会话变量跟踪普通变量的寄存器全局变量,因此需要明确设置它们,例如$_SESSION['myvar'] = $myvar;S_SESSION['school'] = path to the file

如果$dett['sub_opt']来自上一页,则需要$_POST[...个变量。或者你需要在第一个if语句之前从数据库中获取它。