Display entered text with echo after input PHP

前端 未结 1 638
青春惊慌失措
青春惊慌失措 2020-12-20 03:13

I want to do something very simple. After a user enters text in an HTML text box then hits submit, the PHP echo\'s the entered text. I searched all over and I cant find out

相关标签:
1条回答
  • 2020-12-20 04:10

    FTFY

    <html>
    <head><title>some title</title></head>
    <body>
      <form method="post" action="">
        <input type="text" name="something" value="<?= isset($_POST['something']) ? htmlspecialchars($_POST['something']) : '' ?>" />
        <input type="submit" name="submit" />
      </form>
    
    <?php
    if(isset($_POST['submit'])) {
      echo 'You entered: ', htmlspecialchars($_POST['something']);
    }
    ?>
    </body>
    <html>
    
    0 讨论(0)
提交回复
热议问题