Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:59:31+00:00 2026-05-26T09:59:31+00:00

I got a POST form, and it does send the data to the same

  • 0

I got a POST form, and it does send the data to the same file, and if use hit the back button in his browser, he can easily just re-send the data, and it’ll be still read.

Is there any way to avoid such behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:59:31+00:00Added an answer on May 26, 2026 at 9:59 am

    The link Levi sent will answer for you. But in case you want an alternative, here is how I do it…

    User posts to a class, like yours. same file. In the beginning of the class I do post processing. For this example I will make it very simple…

    <?php
    session_start();
    
    //set form vars ahead of time so you can pre-populate the value attr on post
    $form = array(
        'name' => '',
        'email' => ''
    );
    
    if(!empty($_POST))
    {
        //do some kind of validation...
        $errors = array();
        if(trim($_POST['name']) == '')
            $errors[] = 'Please enter your name';
    
        if(empty($errors))
        {
            $_SESSION['message'] = 'Thank you for participating';
            header('location: /form.php'); // same file
            exit;
        }
        else
        {
            // set the form vars to the post vars so you don't lose the user's input
            $form['name'] = $_POST['name'];
            $form['email'] = $_POST['email'];
    
            $message = '<span style="color:red">';
            foreach($errors AS $error)
            {
                $message .= $error."<br />";
            }
            $message .= '</span>';
            $_SESSION['message'] = $message;
        }
    }
    
    if(isset($_SESSION['message']))
    {
        echo $_SESSION['message'];
        unset($_SESSION['message']);
    }
    ?>
    <form id="some_form" action="" method="post">
        <fieldset>
            <label for="name">Name</label> <input type="text" name="name" value="<?php echo $form['name']; ?>" />
            <br /><br />
            <label for="email">Email</label> <input type="text" name="email" value="<?php echo $form['email']; ?>" />
            <br /><br />
            <input type="submit" name="submit" value="Submit" />
        </fieldset>
    </form>
    

    Now you can refresh over and over and not submit the form twice.

    Edited to show further example. Obviously your validation and error handling should be a bit more sophisticated than this, but this should get you in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a form and I need to post data to the server every
I've got an iPhone App that is supposed to send POST data to my
I have a simple form. Its got one field and a submit button. I
My form does not go to recipient when submitted! I changed the file mail.tpl.txt
this is my view for /weather: JSP FILE .... <form method=post action=/spring/krams/show/city> <select name=city>
I've got a PHP/Mysql app that lets users post text from a form. When
In a different post I got a reply that tells about Repetitive SQL. Could
I post this previously in Adobe Forum but haven't got any answers so far.
I've got this date time string: post[date] = 2007-07-18 10:03:19 I'd like to extract
(Scroll down to bottom of post to find solution.) Got a asp.net page which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.