You are here: Re: Clearing POST DATA for Browser Refresh « PHP Programming Language « IT news, forums, messages
Re: Clearing POST DATA for Browser Refresh

Posted by Jerry Stuckle on 02/15/06 03:32

tmax wrote:
> Thank You Dave!!!
>
> This code works - I used ob_start() to get around some header() errors,
> but after implementing that, my form and page works exactly as I
> intended it to. Learned quite a bit from all of this too. Thanks again!
>
> Travis
>
>
> d wrote:
>
>> "tmax" <tmax@comcast.net> wrote in message
>> news:1f9bd$43f23b15$481a8e8e$29885@PGTV.COM...
>>
>>> Well, I've tried everything that has been suggested so far - thanks
>>> for everyone's input.
>>>
>>> However, let me restate the problems differently as I believe it
>>> wasn't correct to begin with.
>>
>>
>>
>> I understand completely what you're asking :)
>>
>> Try this code:
>>
>> <?
>>
>> session_start();
>>
>> if (isset($_POST["data"])) {
>> $_SESSION["data"]=$_POST["data"];
>> session_write_close();
>> header("Location: ".$_SERVER["SCRIPT_URI"]);
>> exit();
>> }
>>
>> if (isset($_SESSION["data"])) {
>> ?>
>> <html>
>> <head><title>Thanks!</title></head>
>> <body>
>> Thank you for submitting your data:<br>
>> <?=$_SESSION["data"];?>
>> </body>
>> </html>
>> <?
>> } else {
>> ?>
>> <html>
>> <head><title>Please Submit</title></head>
>> <body>
>> Use the form to submit your data:<br>
>> <form method="post">
>> <input type="text" name="data"><br>
>> <input type="submit" value="Go!">
>> </form>
>> </body>
>> </html>
>> <?
>> }
>> ?>
>>
>> It will show a form, and take that posted data and store it in a
>> session. Then, the script re-directs you back to itself, and that
>> redirection stops your browser wanting to resubmit the data when
>> refreshed. The session is then checked, and if the data is present, a
>> thank-you note is displayed. If not, it then shows the initial form.
>>
>> dave
>>

His code should work fine as long as you don't have *anything* before
the first line - including blank lines, spaces and DOCTYPE statements.

You should not need ob_start().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация