Jump to content

Recommended Posts

Hope someone help me out about this problem.. I have a form to select user needed categories from it. I use check boxes for this form to let them to select categories. At the time they selected categories I am saving that selected categories on SESSION and after that category page redirect to the next page.

That process is something like this...

if ( $totalCategory >= 1 && $totalCategory <= 10 ) {

   $_SESSION['category'] = $_POST['category']; 

   $url = BASE_URI . 'select_subject.php'; // Define the URL:      
           header("Location: $url");
           exit(); // Quit the script. 
}

 

My problem is when category (after category select) page redirect to the next page (select_subject.php) sometimes user may need to go back to the category page again using

clicking

back button on browser to change again their selected category. But when it happen, it is not going to category page again and browsers display an error something like this...

 

 

Document Expired,

This document is no longer available.

NOTE: But when I click page reload button page display properly.

With this case I need to help from someone to avoid from this and I need to display category page again with displaying previously selected categories properly..

Hope someone help me out.. Thank you..

Link to comment
https://forums.phpfreaks.com/topic/273357-how-i-prevent-from-this-problem/
Share on other sites

I can't tell you how to use it with $_SESSION as I'm using for these purposes sessionStorage in Javascript. It save all my inputs selected (select, checkbox etc.) so when I'm going backwards or reloading page: I'm getting and setting all inputs from that automagically. Perhaps somebody knows better what to do in your case. Good luck!

As far as I know this depends entirely upon your browser, and how it's set up. With Opera it simply reloads from cache, not sending anything to the server (unless the cache settings states otherwise), showing you exactly what you saw before pressing submit.

Other browsers ask whether or not the post data, that was posted to create that page, should be re-submitted. Unless you've turned it off, which seems to be what you've done.

 

You might be able to get around this by using GET, which you should if you're not adding data to your system when selecting categories. (Which it sounds like you're not.)

After you finish processing the POST data, you need to redirect to the exact same URL of the form processing page so that the last action the browser has for that URL is a GET request.

 

can you please explain this little with an example?

 

Thank you.

@PFMaBiSmAd.. your solution is ok. but problem is I need to redirect to anther page after form processing submitted data. Like this

 

 // If category form from category.php successfully submitted then go to next page (subject.php)
$_SESSION['category'] = $_POST['category']; 
$url = BASE_URI . 'subject.php'; // Define the URL:        
       header("Location: $url");
       exit(); // Quit the script. 

 

My problem is when I need to go to category.php page from subject.php page clicking on browser's back button its not going and not loading the page.

I tried using GET method instead of POST then working but always I cant use GET method.

 

Can I know is there a solution with POST method?

 

Thank you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.