1

I've multiple forms to navigate from starting form to final, I've NEXT and BACK buttons in each form in order to go forward and backward. What I want is to avoid confirmation of resubmission of form (Confirm Form Resubmission) ad my forms are using PHP Sessions and GET/POST values.

What is the best approch to avaoid this according to my current scenario?

I've a couple of things that are same over all in all forms

<input type="submit" name="PreviousSubmit" value="<<" class="submit_button" id="PrevSubmit">

and form name: name="myform"

The Jquery onclick action,

jQuery(function () {


      // Back button
      $("#PrevSubmit").click(function () {
          history.go(-1);
          return false;
      });
});

What is the best approach in order to get the previous page without the confirmation of resubmission.

0

1 Answer 1

1

you can redirect to another page in php or js after submitting successfully to clear the $_POST.

in php

header('Location: http://your_page.php');
Sign up to request clarification or add additional context in comments.

4 Comments

$POST isn't wokring as jquery handles on click. can i take the previous document.referr and then apply header in php ?
@developer, A.B is saying when someone submits a form, do your processing, validating, store in session...whatever you would normally do and then perform a header redirect to the next page. This will stop the resubmit page from showing at all.
@JonathanKuhn I totally understand the point of A.B but all what I want to make a general scenario and want to include javascript with header function of PHP
Javascript can't do a header redirect. Headers are something sent with the server response. JS is client side. The headers are already done by the time JS starts. Without redirecting the user, using any sort of browser history for navigation will show that page. Whether that is the user pressing back or you redirecting back with JS. The only other way to "go back" in javascript with out that page is to not use history. Just go forward to the previous URL and fill in the form with the previously submitted data. page1 -> page2 -> page1 (fill in form with previous submitted data).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.