簡體   English   中英

PHP產生一個空白網頁

[英]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有問題?

存在以下問題:

  1. 您的第一個(如果未關閉)括號。 所以關閉它。

  2. 您的表單方法不正確。 拼寫錯誤:-

所以正確的代碼在這里:

<?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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM