提交后的空白页

时间:2015-12-25 10:45:21

标签: php

我一直忙于创建登录脚本,唯一的问题是我在提交登录表单后得到一个空白页面。我正在使用模板系统。

一些代码,

login.tpl:

<div class="container">
    <form class="form-login" action="/customer/login/submit" method="post">
        <h2 class="form-login-heading">$site_name Customer Panel</h2>
            <div class="login-wrap">
                <input type="text" name="loginusername" class="form-control" placeholder="Username" autofocus>
                <input type="password" name="loginpassword" class="form-control" placeholder="Password">
                <button class="btn btn-lg btn-login btn-block" type="submit" name="login">Log in</button>
                <center>
                    <div class="registration">
                        Don't got an account yet?
                        <a class="" href="$site_url/customer/register">
                            Create an account
                        </a>
                    </div>
                </center>
            </div>
        </form>

Submit.php:

    <?php
if (!isset($_POST['loginusername'], $_POST['loginpassword']))
{
    Site::Stop('/customer/login');
}

$Error = Users::Login($_POST['loginusername'], $_POST['loginpassword']);

if (isset($_SESSION['username']))
{
    Site::Stop('/customer/dashboard');
}

$_SESSION['login_error'] = $Error;
Site::Stop('/customer/login');

?>

的login.php:

 $this->Define('LoginError', '');

if (isset($_SESSION['login_error']))
{
    $errors = Array(
        1 => 'This username does not exist.',
        2 => 'Your password is incorrect.');

    if ($_SESSION['login_error'] == 3)
    {
        $errors[3] = '  Your '.$_SESSION['ban']['bantype'].' is banned. 
                Reason: '.$_SESSION['ban']['reason'].'. 
                Your ban expires on: '.date('d-m-y H:i:s', $_SESSION['ban']['expire']);

        unset($_SESSION['ban']);
    }

    $this->Define('LoginError', '<div class="well well-danger">'.$errors[$_SESSION['login_error']].'</div>');
    unset($_SESSION['login_error']);

}

$this->LoadTpl('Login');

Maps.php

    <?php
$this->Map('/customer/login', 'Login.php');
$this->Map('/customer/register', 'Register.php');
$this->Map('/customer/register/submit', 'RegSubmit.php');

if (Users::$Session === false)
{
    $this->Map('/customer/login/submit', 'Submit.php');
}
else
{
    $this->Map('/customer/logout', 'Logout.php');
}
?>

1 个答案:

答案 0 :(得分:0)

确保会话已在php文件顶部的session_start()开始。