homepage Welcome to WebmasterWorld Guest from 54.167.174.90
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Form keeps resending information on reload.
duckxtales

10+ Year Member



 
Msg#: 3182216 posted 7:18 am on Dec 8, 2006 (gmt 0)

Hi,

I have PHP form that is basically a contact page when the user clicks on submit. I have the page update with your message that says it has been sent, but now if the user clicks on reload it ask to resubmit the information over again. And that's where i want to stop this so when the user clicks on reload it will not resubmit the information again. How can this be done?

thanks,
pat

 

mcibor

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3182216 posted 8:44 am on Dec 8, 2006 (gmt 0)

Hi Pat!

You can insert redirecting, even to the same page. Then on reload page will be sent without post data.

To redirect you can use

<meta http-equiv="Refresh" content="0;url=<?php echo $HTTP_SERVER_VARS[PHP_SELF];?>">

Regards
Michal

duckxtales

10+ Year Member



 
Msg#: 3182216 posted 6:32 pm on Dec 8, 2006 (gmt 0)

that doesnt seem to work. it just keeps refreshing non-stop. i put it in the < head >

mcavic

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3182216 posted 3:26 am on Dec 9, 2006 (gmt 0)

After the form data has been handled, use a Location redirection to go to a different page.

header("Location: thank_you.php");

Also, at the very top of the same handling script, say:
ob_start();

That will ensure that the header() works.

compose

5+ Year Member



 
Msg#: 3182216 posted 11:19 am on Dec 9, 2006 (gmt 0)

Hello,

After performing necessary work with coming data you can use unset($_POST) to flush $_POST array.

It may help you.

Vinic

mcavic

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3182216 posted 5:01 pm on Dec 9, 2006 (gmt 0)

Oops, I lied. I use Location redirects on all my forms, but it doesn't prevent the refresh problem.

<meta http-equiv="Refresh" content="0;url=<?php echo $HTTP_SERVER_VARS[PHP_SELF];?>">

This is the answer, but you probably have to redirect to a different page, not the same one.

<meta http-equiv="Refresh" content="0;url=http://site/thank_you.php">

mcibor

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3182216 posted 9:55 pm on Dec 12, 2006 (gmt 0)

or just redirect when there is POST data:

if(isset($_POST))
{
echo "<meta http-equiv=\"Refresh\" content=\"0;url=".$HTTP_SERVER_VARS[PHP_SELF]."\">";
//... and parse the POST however you like.
}

Hope this helps
Michal

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved