This question already has answers here:
PHP parse/syntax errors; and how to solve them?
(17个答案)
三年前关闭。
我试图输出用户输入到网站的信息。这是我在页面第一部分的代码,显示了填写的信息(此代码有效):
但是,处理输入数据的页面不起作用。我的代码如下:
我试图根据用户输入的数据输出屏幕右侧小文本框中的内容:
![php - 输出HTML用户输入*使用HTML代码*-LMLPHP php - 输出HTML用户输入*使用HTML代码*-LMLPHP]()
我在想是否有人能帮我!
(17个答案)
三年前关闭。
我试图输出用户输入到网站的信息。这是我在页面第一部分的代码,显示了填写的信息(此代码有效):
<form action = "comment_process.php" method = "post">
Name:
<input type = "text" name = "name"/> <br>
Do you like this page?
<input type = "radio" name = "answer" value = "Yes"> Yes
<input type = "radio" name = "answer" value = "No"> No <br>
Comment:
<textarea rows="3" cols="50" name = "comment"/> </textarea> <br>
Rating
<select name = "rating"> <br>
<option value = "0"> 1 </option>
<option value = "1"> 2 </option>
<option value = "2"> 3 </option>
<option value = "3"> 4 </option>
<option value = "4"> 5 </option>
<input type = "submit" value = "go"/>
</form>
但是,处理输入数据的页面不起作用。我的代码如下:
<?php
$v = $_POST['firstname'];
$x = $_POST['comment'];
$y = $_POST['answer'];
$z = $_POST['rating'];
echo "Hello $v! <br>"
if ($y == "Yes") {
echo "I am happy that you like the page :)"
}
else {
echo "I am sorry that you do not like the page :("
}
echo "Thanks for your comment [$x]";
echo "You rated our page as Rating $z";
?>
我试图根据用户输入的数据输出屏幕右侧小文本框中的内容:
我在想是否有人能帮我!
最佳答案
你犯了一些错误
这对我有效:
<form action = "comment_process.php" method = "post">
Name:
<input type = "text" name = "name"/> <br>
Do you like this page?
<input type = "radio" name = "answer" value = "Yes"> Yes
<input type = "radio" name = "answer" value = "No"> No <br>
Comment:
<textarea rows="3" cols="50" name = "comment"/> </textarea> <br>
Rating
<select name = "rating"> <br>
<option value = "0"> 1 </option>
<option value = "1"> 2 </option>
<option value = "2"> 3 </option>
<option value = "3"> 4 </option>
<option value = "4"> 5 </option>
<input type = "submit" value = "go"/>
</form>
<?php
$v = $_POST['firstname'];
$x = $_POST['comment'];
$y = $_POST['answer'];
$z = $_POST['rating'];
echo "Hello $v";
if ($y == "Yes") {
echo "I am happy that you like the page :)";
}
elseif ($y == "No") {
echo "I am sorry that you do not like the page :(";
}
echo "Thanks for your comment [$x]";
echo "You rated our page as Rating $z";
?>