post v get

This is a discussion on post v get within the PHP General forums, part of the PHP Programming Forums category; When you POST a form to the server the server replies with a new page. if you click the Back ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-28-2003
Andu
 
Posts: n/a
Default post v get

When you POST a form to the server the server replies with a new
page. if you click the Back button in the browser the server wants to
re-POST the form. Short of using GET is there a way to prevent
re-submitting the previous form?

--
Regards, Andu Novac
Reply With Quote
  #2 (permalink)  
Old 08-28-2003
Jim Lucas
 
Posts: n/a
Default Re: [PHP] post v get

no

Jim Lucas
----- Original Message -----
From: "andu" <php@archeopterix.com>
To: <php-general@lists.php.net>
Sent: Thursday, August 28, 2003 1:49 PM
Subject: [php] post v get


> When you POST a form to the server the server replies with a new
> page. if you click the Back button in the browser the server wants to
> re-POST the form. Short of using GET is there a way to prevent
> re-submitting the previous form?
>
> --
> Regards, Andu Novac
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply With Quote
  #3 (permalink)  
Old 08-28-2003
John W. Holmes
 
Posts: n/a
Default Re: [PHP] post v get

andu wrote:

> When you POST a form to the server the server replies with a new
> page. if you click the Back button in the browser the server wants to
> re-POST the form. Short of using GET is there a way to prevent
> re-submitting the previous form?


Of course. :)

One technique is to use a "middle-man" page that processes your POST
data and inserts it into the database or file or whatever. Then you use
header() to send the user to another page.

So the page that was "posted" to is never really seen by the user and
the back button just goes back directly to the form. You can also go
back to the redirected page without the browser asking to "re-post" the
data...

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
Reply With Quote
  #4 (permalink)  
Old 08-29-2003
David Otton
 
Posts: n/a
Default Re: [PHP] post v get

On Thu, 28 Aug 2003 18:50:55 -0400, you wrote:

>> When you POST a form to the server the server replies with a new
>> page. if you click the Back button in the browser the server wants to
>> re-POST the form. Short of using GET is there a way to prevent
>> re-submitting the previous form?


>One technique is to use a "middle-man" page that processes your POST
>data and inserts it into the database or file or whatever. Then you use
>header() to send the user to another page.


Here's a quick fragment to illustrate the technique. It requires a file
called "list.txt" to exist.

<?
if (isset ($item)) {
$fp = fopen("list.txt", "a");
fputs ($fp, "<tr><td>$item</td></tr>\r\n");
header ("Location: $PHP_SELF");
exit();
}
?>
<table border="1" cellspacing="2">
<?
readfile("list.txt");
?>
</table>
<br><br>
<form method="post" action="<? echo ($PHP_SELF); ?>">
<p>Add Item: <input type="text" name="item"></p>
<p><input type="submit" name="Add" value="Add"></p>
</form>
Reply With Quote
  #5 (permalink)  
Old 08-29-2003
Andu
 
Posts: n/a
Default Re: [PHP] post v get

On Fri, 29 Aug 2003 02:06:55 +0100
David Otton <phpmail@jawbone.freeserve.co.uk> wrote:

> On Thu, 28 Aug 2003 18:50:55 -0400, you wrote:
>
> >> When you POST a form to the server the server replies with a new
> >> page. if you click the Back button in the browser the server wants

> >to> re-POST the form. Short of using GET is there a way to prevent
> >> re-submitting the previous form?

>
> >One technique is to use a "middle-man" page that processes your POST
> >data and inserts it into the database or file or whatever. Then you
> >use header() to send the user to another page.

>
> Here's a quick fragment to illustrate the technique. It requires a
> file called "list.txt" to exist.
>
> <?
> if (isset ($item)) {
> $fp = fopen("list.txt", "a");
> fputs ($fp, "<tr><td>$item</td></tr>\r\n");
> header ("Location: $PHP_SELF");
> exit();
> }
> ?>
> <table border="1" cellspacing="2">
> <?
> readfile("list.txt");
> ?>
> </table>
> <br><br>
> <form method="post" action="<? echo ($PHP_SELF); ?>">
> <p>Add Item: <input type="text" name="item"></p>
> <p><input type="submit" name="Add" value="Add"></p>
> </form>
>


Thanks David.


--
Regards, Andu Novac
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0