search

Home  >  Q&A  >  body text

PHP does not echo form data stored in variables

<html>
<body>
    <form name="formularz" action="#" method="post">
        <input type="text" name="t" value="tekst" />
        <input type="hidden" name="h" value="ukryte" />
        <input type="password" name="p" value="hasło" />
        <button type="submit">Wyślij</button>
    </form>
    
    <?php
    if(isset($_POST['t']) && isset($_POST['h']) && isset($_post['p']))
    {
        
        $t = (isset($_POST['t'])?  $_POST['t']: '');
        $h = (isset($_POST['h'])?  $_POST['h']: '');
        $p = (isset($_POST['p'])?  $_POST['p']: '');
        
        echo "<p>text=$t,    hidden=$h, password=$p",    '</p>';
    }
    ?>
</body>
</html>

The code above should create a form and then display it via a php script. This is a 1:1 copy of my teacher resource that other students can use. The class collectively called it the same, and the mystery of its eventual failure remains unsolved to this day.

There is no error warning, the script just doesn't display anything after submitting the form. please help me.

P粉078945182P粉078945182275 days ago548

reply all(1)I'll reply

  • P粉322319601

    P粉3223196012024-04-03 09:52:17

    Your condition is wrong. The last method isset is $_post in lowercase and should be like this: if(isset($_POST['t']) && isset($_POST['h']) && isset ($ _POST['p']))

    reply
    0
  • Cancelreply