我尝试过的所有显示错误的方法,仍然让我死灰复燃。

请注意,我正在使用XAMPP开发网站。
我还有什么可以做的吗?还要看看我的代码,因为我不知道它是否有效。

代码如下:

<?php

error_reporting(-1);  // Have PHP complain about absolutely everything
$conf['error_level'] = 2;  // Show all messages on your screen, 2 = ERROR_REPORTING_DISPLAY_ALL.
ini_set('display_errors', TRUE);  // These lines just give you content on WSOD pages.
ini_set('display_startup_errors', TRUE);

require("dbconn.php");
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

    $Username   =   $_POST['username']; #Username
    $Password   =   $_POST['password']; #Password

function InsrtUser()
{
    global $Username,$Password;
    #Egxwrish stoixeiwn
    $hashed_pass = PASSWORD_HASH($Password, PASSWORD_DEFAULT);
    $query = "INSERT INTO users (username,password) VALUES (:username, :password)";
    $data = $mysqli->prepare($query);
    $data->execute(array(':username'=>$Username, ':password'=>$hashed_pass));
    if($data->rowCount() > 0)
    {
        return "YOUR REGISTRATION IS COMPLETED...";
    }
}

function Register()
{
    global $Username,$Password;
    if(!empty($Username))   //checking the 'username' name which is from register.html, if is it empty or have some text
        {
                $query = ("SELECT * FROM users WHERE username = :username");
                $query = $mysqli->prepare($query);
                $query->execute(array(':username'=>$Username));
                if($query->rowCount() == 0)
            {
                $msg = InsrtUser();
                echo $msg;
            }
            else {
                echo "SORRY...YOU ARE ALREADY registerED USER...!";
                die();
            }

        }
}

if(isset($_POST['submit']))
{
    //User registration
    Register();
    echo "Your account has been created successfully. \\n Thank you for joined us!";
    $msgSuccess = "Your account has been created successfully. \\n Thank you for joined us!";
        echo
            "<script>
            alert('$msgSuccess');
            window.location.href='../index.php';
            </script>";

}
?>

最佳答案

实际上,这不是您遇到的死亡筛选方案。如果设置了$_POST['submit'],则仅输出内容。如果未设置,则不会输出任何内容,因此,白屏(无内容)是期望值,这是您得到的结果。

我认为问题是您的提交按钮没有名称属性submit

将来添加else也将帮助您调试这些。

if(isset($_POST['submit']))
{
    //User registration
    Register();
    echo "Your account has been created successfully. \\n Thank you for joined us!";
    $msgSuccess = "Your account has been created successfully. \\n Thank you for joined us!";
        echo
            "<script>
            alert('$msgSuccess');
            window.location.href='../index.php';
            </script>";

} else {
    echo 'The submit button is not set :(';
}

10-07 17:56