我正在构建基于PHP的登录/创建帐户脚本。只要文件顶部的PHP被注释掉/不存在,表单就会正确显示。一旦我将php放入文件中,表单就会消失。任何人都可以看到他们是否找到了为什么会发生这种情况的原因?
谢谢, 马特
//编辑 所以我发现错误存在于if / else语句中,用于检查密码是否匹配。如果我注释掉else语句,页面会正确显示,一旦注释掉,我就会得到一个空白页面。我甚至注释掉了mysql_query(),只是输入一个简单的回声,没有运气。
$db_found2 = conServer();
if($db_found2) {
if (!empty($_POST['username']) || !empty($_POST['password']) || !empty($_POST['email']) || !empty($_POST['conpassword'])) {
$username = $_POST['username'];
$password = $_POST['username'];
$conpassword = $_POST['conpassword'];
$email = $_POST['email'];
if ($password != $conpassword) {
$errormsg = "";
$passerr = "Passwords do not match!";
}
}
}
function conServer() {
$user_name = ""; //not displayed for privacy purposes
$password = ""; //not displayed for privacy purposes
$database = ""; //not displayed for privacy purposes
$server = "localhost";
$table = "users";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
return $db_found;
}
?>
<html>
<head>
<link rel=stylesheet href="login.css" />
</head>
<body class="login">
<div id="login">
<form id="loginform" action="create.php" method="post">
<p>
<label for="username">
Username *
<br>
<input type="text" name="username" id="username"/><span class="error"><?php echo $errormsg; ?></span>
</label>
</p>
<p>
<label for="password">
Password *
<br>
<input type="password" name="password" id="password"/><span class="error"><?php echo $errormsg; ?></span>
</label>
</p>
<p>
<label for="password">
Confirm Password *
<br>
<input type="password" name="conpassword" id="password"/><span class="error"><?php echo $errormsg; ?></span><span class="error"><?php echo $passerr; ?></span>
</label>
</p>
<p>
<label for="email">
Email *
<br>
<input type="text" name="email" id="email" /><span class="error"><?php echo $errormsg; ?></span>
</label>
</p>
<input type="submit" id="submit" value="Go ->"/>
</form>
</div>
</body>
</html>
答案 0 :(得分:4)
脚本中可能存在错误导致脚本终止。如果错误报告已关闭,您只能获得一个白页。
如何启用error reporting:
error_reporting(E_ALL | E_STRICT);
同时检查display_errors设置:
ini_get('display_errors');
答案 1 :(得分:3)