Connecting Tech Pros Worldwide Forums | Help | Site Map

Preventing "Are you sure you want to resend POST data?" warnings

Newbie
 
Join Date: Aug 2007
Posts: 1
#1: Aug 21 '07
Hi

I need small help,

What I need is when I write a script to handle my post data on my login page. if login failed and i press refresh key browser shows msg to resend the post data

I tried unset() function too, But it didn't work. Do any one have
anything for me ?

Thanks In advance
Regards
Kaushal

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Aug 21 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Heya, Kaushal. Welcome to TSDN!

You posted this in the Articles section. I'll go ahead and move it to the Forum where an Expert will be more likely to find it.

Changed thread title to better describe the problem (did you know that threads whose titles that do not follow the Posting Guidelines actually get FEWER responses?).
Purple's Avatar
Moderator
 
Join Date: May 2007
Location: UK - North West
Posts: 385
#3: Aug 22 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Hi kiran Vidhate,

can you post the code you have already, it will make it simpler to assist if we can see what you have already.

Regards Purple
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#4: Aug 22 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Heya, Kaushal.

The way to prevent this is to use header() redirection. When the User submits the form, have the form submit to a *separate* page, and then use header() redirection to send him back when you are done.

How header() redirection works
entertainmentliveuk's Avatar
Newbie
 
Join Date: Aug 2007
Location: Dorset, UK
Posts: 9
#5: Aug 23 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Quote:

Originally Posted by kiran Vidhate

Hi

I need small help,

What I need is when I write a script to handle my post data on my login page. if login failed and i press refresh key browser shows msg to resend the post data

I tried unset() function too, But it didn't work. Do any one have
anything for me ?

Thanks In advance
Regards
Kaushal

At the top of the page, after you have processed the data, try this:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3.    if(isset($_REQUEST['bla']))
  4.       {
  5.           process the code here, then...
  6.          echo "<script>
  7.                   document.location.href='thispage.url';
  8.                   </script>";
  9.          exit;
  10.       }
  11. ?>
  12.  
This will process the data, then redirect the user to the same page, without the posted data.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#6: Aug 23 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Quote:

Originally Posted by entertainmentliveuk

At the top of the page, after you have processed the data, try this:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3.    if(isset($_REQUEST['bla']))
  4.       {
  5.           process the code here, then...
  6.          echo "<script>
  7.                   document.location.href='thispage.url';
  8.                   </script>";
  9.          exit;
  10.       }
  11. ?>
  12.  
This will process the data, then redirect the user to the same page, without the posted data.

You can also swap the JavaScript with a header, like pbmods said.
Like so:
Expand|Select|Wrap|Line Numbers
  1. header("Location: thispage.url");
  2.  
entertainmentliveuk's Avatar
Newbie
 
Join Date: Aug 2007
Location: Dorset, UK
Posts: 9
#7: Aug 23 '07

re: Preventing "Are you sure you want to resend POST data?" warnings


Quote:

Originally Posted by Atli

You can also swap the JavaScript with a header, like pbmods said.
Like so:

Expand|Select|Wrap|Line Numbers
  1. header("Location: thispage.url");
  2.  

Oooh I like that one... I have not found that!
I'll try it out on my site.
Reply