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 9125371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:47:20+00:00 2026-06-17T06:47:20+00:00

The reason for this post is that I am trying to avoid the form

  • 0

The reason for this post is that I am trying to avoid the “form re submission error” that most browsers give off when a form is refreshed.

Take the following example:

The user is on a page called signpetition.php and shown a basic HTML form:

<div id="sign-errors" style="display: none;">
</div>

<form action="" method="post">
    <input type="submit" name="submit_button" value="sign petition" />
</form>

So, the user clicks the submit button and now the POST data will be read and verified.

signpetition.php

<?php
    if(isset($_POST['submit_button']))
    {
        // Do some validation

        if($errors == true)
        {
          // What to do here? I want to go back to the last page, but keep the errors. Should I store them in a session variable and then unset them after their use? I feel as though there must be a better solution to this.

            $_SESSION['error'] = "the error";
            header('Location: '. $_SERVER['REQUEST_URI'] , true, 303);
        exit;

        }
        else
        {
            $_SESSION['success'] = "your petition was successfully signed!";
            header('Location: '. $_SERVER['REQUEST_URI'] , true, 303);
        exit;
        }
    }
        ?>

So, to sum things up:

I want to avoid the form re submission issue, which is why I’m using
the header redirection in my code

  • 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-06-17T06:47:21+00:00Added an answer on June 17, 2026 at 6:47 am

    If the users are being redirected, then there should never be a form re-submission.

    Redirect them to submitted.php and use the following:

    if(isset($_SESSION['error'])){ echo'the error';}
    else if(isset($_SESSION['success'])){ echo'your petition was successfully signed!');}
    else{ echo 'unknown error.'; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to perform this AJAX post but for some reason I am
Continuing off this post: Performance hit incurred using NSMutableDictionary vs. NSMutableArray> I am trying
For some reason this program is saying that 'switch' is not defined. What is
I'm trying to follow this blog post: http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx My aim is to somehow get
I'm trying to select all the tags that go with a post in my
The title sort of explains what I'm trying to do. The reason for this
For some reason this isn't working, am I missing something obvious? RewriteRule ^(.*)infopopup.html$ /acatalog/infopopup.html
For some reason this line of code is giving me quite a problem. struct
For some reason this () character shows up in Firefox 10 randomly throughout my
For one or another reason this code sample gives 48 hours instead of 24,

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.