Html表单值没有在PHP中显示

时间:2017-02-02 07:42:33

标签: php html

请用户在输入dosen&t输入的值在PHP中显示。这是代码

<html>

<head></head>
<form method="post" action="hiUser.php">
    Please type your name
    <input type="text" name="u" value="">
    <input type="submit">
</form>
</body>

</html>

这是php代码

<html>

<body>
    <h3> hi user, </h3>
    <?
            echo $_ POST['u']
             Print $u
             ?>
</body>

</html>

2 个答案:

答案 0 :(得分:1)

  

form.php的

<html>

<head></head>
<form method="post" action="hiUser.php">
    Please type your name
    <input type="text" name="u" value="">
    <input type="submit">
</form>
</body>

</html>
  

hiUser.php

<html>

<body>
    <h3> hi user, </h3>
    <?php
        echo $u = $_POST['u'] ;
    ?>
</body>

</html>

答案 1 :(得分:0)

如果您尚未启用short_open_tags

<? echo $_ POST['u']
     Print $u
  ?>

必须像这样

<?php $u = $_POST['u'];
     echo $u;
  ?>