我想寫一個簡單的PHP窗體,但出來是不同於我想要它是。有沒有人看到我的錯誤是多謝,並感謝。 作業: 編寫一個PHP腳本,用於檢查從表單發送的消息,然後打印發件人和消息的名稱。如果發件人姓名或消息爲空,請打印「您沒有提供所有必需的信息!」刪除用戶名或消息之前或之後的任何空格。也刪除任何HTML標籤,以確保用戶不能改變留言簿。所使用的形式如下:簡單的PHP窗體1
<form action="guestbook.php" method="get">
Sender: <input TYPE="text" name="name"><br>
Message: <input type="text" name="message"><br>
<input type="submit" value="Send">
</form>
Example output
John: Hello!
**my script:**
<?php
$name = $_GET["name"];
if(isset($_GET['submit'])) {
echo "$name: Hello!";
} else {
echo "You didn’t give all required information!";
}
?>
YOUR PROGRAM DOES NOT OPERATE CORRECTLY
Your program generated the following output:
You didn’t give all required information!
The following output should have been generated:
John: Hello!
The white area indicates correct output from your program.
represents a carriage return
In the comparison of outputs, the output of your program must be exactly the same as the example output.
嗨,感謝您的幫助,當我嘗試您的代碼輸出是不同的我們的程序不能正常運行 您的程序生成以下輸出: John:您好! \t \t 應生成以下輸出: 您沒有提供所有必需的信息! 白色區域表示程序輸出正確。 表示回車 在輸出的比較中,程序的輸出必須與示例輸出完全相同。 – user3314727
您有原始問題未指定的附加要求。這聽起來像你的要求是在顯示消息之前檢查_both_名稱_and_消息是否已設置。嘗試改變這行以說'if(isset($ _ GET ['name'])&& isset($ _ GET ['message'])){'。 – Adam