我已经尝试过关于显示错误的所有内容,但我仍然会看到死亡的白屏。
请注意,我正在使用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>";
}
?>
答案 0 :(得分:0)
这实际上不是您遇到的死亡屏幕情况。如果设置了$_POST['submit']
,则只输出内容。如果没有设置,则不输出任何内容,因此白色屏幕(无内容)是预期值,这就是你得到的。
我认为问题在于您的提交按钮没有名称属性submit
。
将来添加其他内容也可以帮助您调试这些..
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 :(';
}