诊断PHP登录表单问题

诊断PHP登录表单问题,php,redirect,login,usercake,Php,Redirect,Login,Usercake,我不想找任何人帮我做所有的跑腿工作,但我有一个开源项目,它可以在大多数服务器上完美地工作,但是一个人的服务器,当你去注册或登录时,页面只是刷新而不是登录。没有任何东西进入数据库 一个$u POST的var_转储看起来一切都很好,我在表单中剥离了尽可能多的数据验证,但没有骰子 Chrome或Firefox/Firebug中是否有工具可以帮助我了解发生了什么?Chrome上的一个控制台日志基本上告诉我页面已经被重新加载,但没有其他内容。我的错误都不会再出现在页面上了。这只是一个简单的页面刷新 这是未

我不想找任何人帮我做所有的跑腿工作,但我有一个开源项目,它可以在大多数服务器上完美地工作,但是一个人的服务器,当你去注册或登录时,页面只是刷新而不是登录。没有任何东西进入数据库

一个$u POST的var_转储看起来一切都很好,我在表单中剥离了尽可能多的数据验证,但没有骰子

Chrome或Firefox/Firebug中是否有工具可以帮助我了解发生了什么?Chrome上的一个控制台日志基本上告诉我页面已经被重新加载,但没有其他内容。我的错误都不会再出现在页面上了。这只是一个简单的页面刷新

这是未编辑(减去一堆html)的登录文件。它基于一个名为UserCake的旧系统。其中大部分是遗留代码。我要从头开始完全重写这个项目

<?php require_once("models/top-nav.php"); ?>

<!-- If you are going to include the sidebar, do it here -->
<?php //require_once("models/left-nav.php"); ?>
</div>
<!-- /.navbar-collapse -->
</nav>
<!-- PHP GOES HERE -->
<?php
//Prevent the user visiting the logged in page if he/she is already logged in
if(isUserLoggedIn()) { header("Location: account.php"); die(); }

//Forms posted
if(!empty($_POST))
{
    $token = $_POST['csrf'];
    if(!Token::check($token)){
        die('Token doesn\'t match!');
    }
    //reCAPTCHA 2.0 check
    // empty response
    $response = null;

    // check secret key
    $reCaptcha = new ReCaptcha($privatekey);

    // if submitted check response
    if ($_POST["g-recaptcha-response"]) {
        $response = $reCaptcha->verifyResponse(
            $_SERVER["REMOTE_ADDR"],
            $_POST["g-recaptcha-response"]
        );
    }
    if ($response != null && $response->success) {

    $errors = array();
    $username = sanitize2(trim($_POST["username"]));
    $password = trim($_POST["password"]);

    //Perform some validation
    //Feel free to edit / change as required
    if($username == "")
    {
        $errors[] = lang("ACCOUNT_SPECIFY_USERNAME");
    }
    if($password == "")
    {
        $errors[] = lang("ACCOUNT_SPECIFY_PASSWORD");
    }

        //A security note here, never tell the user which credential was incorrect
        if(!usernameExists($username))
        {
        $errors[] = lang("ACCOUNT_USER_OR_PASS_INVALID");
        }
        else
        {
            $userdetails = fetchUserDetails($username);
            //See if the user's account is activated
            if($userdetails["active"]==0)
            {
                $errors[] = lang("ACCOUNT_INACTIVE");
            }
            else
            {
                //- THE OLD SYSTEM IS BEING REMOVED - Hash the password and use the salt from the database to compare the password.
                //$entered_pass = generateHash($password,$userdetails["password"]);
                $entered_pass = password_verify($password,$userdetails["password"]);


                if($entered_pass != $userdetails["password"])
                {

                    $errors[] = lang("ACCOUNT_USER_OR_PASS_INVALID"); //MAKE UPGRADE CHANGE HERE

                }
                else
                {
                    //Passwords match! we're good to go'

                    //Construct a new logged in user object
                    //Transfer some db data to the session object
                    $loggedInUser = new loggedInUser();
                    $loggedInUser->email = $userdetails["email"];
                    $loggedInUser->user_id = $userdetails["id"];
                    $loggedInUser->hash_pw = $userdetails["password"];
                    $loggedInUser->title = $userdetails["title"];
                    $loggedInUser->displayname = $userdetails["display_name"];
                    $loggedInUser->username = $userdetails["user_name"];


                    //Update last sign in
                    $loggedInUser->updateLastSignIn();
                    $_SESSION["userCakeUser"] = $loggedInUser;

                    //Redirect to user account page
                    header("Location: account.php");
                    die();
                }
            }
        }
    }
}

?>


<?php
echo resultBlock($errors,$successes);
echo "
<div id='regbox'>
<form name='login' action='".$_SERVER['PHP_SELF']."' method='post'>
<p>
";
?>
<label>Username:</label>
<input  class='form-control' type='text' name='username' />
</p>
<p>
<label>Password:</label>
<input  class='form-control'  type='password' name='password' />
</p>
<p><label>Please enter the words as they appear:</label>
    <div class="g-recaptcha" data-sitekey="<?php echo $publickey; ?>"></div>
</p>
<p>
<label>&nbsp;</label>
<input class='btn btn-primary' type='submit' value='Login' class='submit' />
</p>
<input type="hidden" name="csrf" value="<?=Token::generate();?>" >
</form>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<!-- footer -->
<?php require_once("models/footer.php"); ?>

添加到文件的顶部,这将有助于查找错误

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code
添加到文件顶部,这将有助于查找错误

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

Chrome调试器工具/Firebug中的网络检查器选项卡。在HTTP级别调试应用程序。关于这一点,我们可以说的不多。没有什么特别的(所以不是一个好的so问题-希望它被关闭),但您可以检查该服务器上的错误日志作为开始。另外,检查chrome中的网络工具,看看是否没有胭脂重定向或类似的错误报告,在打开PHP标记后立即将错误报告添加到文件顶部,例如
控制台日志不会告诉您有关PHP的任何信息。它只会告诉您有关JavaScript的信息。我们需要了解一些HTML和PHP。可能是因为该服务器不支持某些可能已弃用的函数。关于服务器是什么、平台是什么、支持什么和不支持什么等细节,您的问题很少。Chrome debugger tools/Firebug中的Network inspector选项卡。在HTTP级别调试应用程序。关于这一点,我们可以说的不多。没有什么特别的(所以不是一个好的so问题-希望它被关闭),但您可以检查该服务器上的错误日志作为开始。另外,检查chrome中的网络工具,看看是否没有胭脂重定向或类似的错误报告,在打开PHP标记后立即将错误报告添加到文件顶部,例如
控制台日志不会告诉您有关PHP的任何信息。它只会告诉您有关JavaScript的信息。我们需要了解一些HTML和PHP。可能是因为该服务器不支持某些可能已弃用的函数。关于服务器是什么、平台是什么、支持什么和不支持什么等细节,您的问题很少。