doulin4844 2014-07-25 15:47
浏览 21
已采纳

在PHP中POST / GET

I have a simple html form

 <!DOCTYPE html>
 <html>
 <form action="trial2.html" method="get">
 <input type="text" name="name">
 <input type="submit">
 </form>
 </html>

which then runs this trial2.html

<!DOCTYPE html>
<html>
<?php
$val = $_GET["name"];
echo($val);
?>
</html>

I cannot work out why echo won't print out "name" although it can print out generic strings

I've been using w3schools as a reference but I think I'm just being stupid somewhere/completely missing the point.

  • 写回答

3条回答 默认 最新

  • duanju7199 2014-07-25 15:49
    关注

    A .html file does not normally contain PHP code.

    Rename your file to the .php extension and adjust your code to point to the renamed file, and change the echo to:

    echo $val;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?