我想写一个简单的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