[英]PHP produces a blank webpage
每当我使用这段PHP时,它都会使网页空白(白色),并且什么也不显示。 这是我的代码:
<?php
if(isset($_POST['submit'])){
//
$user = $_POST['username'];
$pwrd = $_POST['pwrd'];
//include database connection
include('../includes/db_connect.php');
if(empty($user) || empty($pwrd)){
echo 'Missing information';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="container">
<form action="Login.php" mthod="post">
<p>
<label>Username</label><input type="text" name="username" />
</p>
<p>
<label>Password</label><input type="password" name="pwrd" />
</p>
<input type="submit" name="submit" value="logIn" />
</form>
</div>
</body>
</html>
在测试了不同部分的PHP代码之后,我注意到只有此代码使页面空白
if(empty($user) || empty($pwrd)){
echo 'Missing information';
}
?>
这可能与Apache有关,还是我的PHP有问题?
存在以下问题:
您的第一个(如果未关闭)括号。 所以关闭它。
您的表单方法不正确。 拼写错误:-
所以正确的代码在这里:
<?php
if(isset($_POST['submit'])){
//
$user = $_POST['username'];
$pwrd = $_POST['pwrd'];
//include database connection
include('../includes/db_connect.php');
if(empty($user) || empty($pwrd)){
echo 'Missing information';
}
}// missing
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="container">
<form action="Login.php" method="post"> // method is written mthod
<p>
<label>Username</label><input type="text" name="username" />
</p>
<p>
<label>Password</label><input type="password" name="pwrd" />
</p>
<input type="submit" name="submit" value="logIn" />
</form>
</div>
</body>
</html>
输出:-提交前: -http : //prntscr.com/74xhb7提交后: -http : //prntscr.com/74xhmm
注意:-我说过要关闭的括号可以根据您的意愿关闭。 谢谢。
也不要因在第二张屏幕截图中看到的错误而惊慌。 这是因为我最后没有包含文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.