HTML Forms in PHP

后端 未结 2 1748
南旧
南旧 2021-01-15 17:52

i am writing html form code with in php script

here it is



        
相关标签:
2条回答
  • 2021-01-15 18:31

    You should specify a method of form submit.

    $problem_code="STR";
    echo '<form method=post name="submit-button" action="/codejudge/submit.php?id='.$problem_code.'">';
    echo '<button type="submit" >Submit</button>';
    echo "</form>";
    
    0 讨论(0)
  • 2021-01-15 18:40

    If a form is method="GET" (which is the default), as this one is, then submitting it will erase the existing query string in the action.

    Store the data in a hidden input instead.

    <?php
      $problem_code="STR";
    ?>
    <form name="submit-button" action="/codejudge/submit.php">
      <input type="hidden" name="id" value="<?php echo htmlspecialchars($problem_code); ?>">
      <button type="submit">Submit</button>
    </form>
    
    0 讨论(0)
提交回复
热议问题