0

Please, the value entered by the user in the input dosen't show in PHP. This is the code

<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>

This is the php code

<html>

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

</html>
Vivek Singh
  • 2,453
  • 1
  • 14
  • 27
chika
  • 177
  • 1
  • 3
  • 12
  • Do you have [`short_open_tag`](https://secure.php.net/manual/ini.core.php#ini.short-open-tag) enabled? Also `$_ POST['u']` (note the space) might be a typo here, if not, it's invalid. Then there's a `;` missing after `['u']`. You really need to fix the syntax issues first before judging whether your script works. – Yoshi Feb 02 '17 at 07:47
  • Would've been nice to know what *does* show "in PHP". – Torbjörn Stabo Feb 02 '17 at 07:50
  • It shows only Hi user, – chika Feb 02 '17 at 08:56

2 Answers2

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>
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40
0

if you have not enabled short_open_tags

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

must be like this

<?php $u = $_POST['u'];
     echo $u;
  ?>
Vivek Singh
  • 2,453
  • 1
  • 14
  • 27
  • I have tried your correction but it still doesn't show the value imputed by the user. It only shows Hi user, – chika Feb 02 '17 at 08:58