submit form to self

前端 未结 1 1355
无人共我
无人共我 2021-01-22 08:36

At the moment, I have a form with an input (text) and a button to submit the form.

The form is posted to \'submit.php\'. I would like the form posted to same page as th

相关标签:
1条回答
  • 2021-01-22 09:33

    I think you have a couple of options here.

    Submit the form onto itself

    <?php
        if('POST' == $_SERVER['REQUEST_METHOD']) {
            // process the form here
        }
    ?>
    <form action="" method="POST">
        <input type="text" class="emailField" placeholder="email address" name="email" />
        <button type="submit">
            <div class="submit" />
        </button>
    </form>
    

    Redirect back to the form

    Add something like this in submit.php where you want to show the form.

    <?php
        header('Location: http://example.org/form.php');
        exit;
    ?>
    
    0 讨论(0)
提交回复
热议问题