PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Emptying $_POST?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Emptying $_POST?

Réponse
 
LinkBack Outils de la discussion
Vieux 12/02/2008, 11h34   #1
Gilles Ganault
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Emptying $_POST?

Hello

I use a POST variable named "status" to show different screens while
keeping everything in the same script.

The problem is that in the Print screen, I need to empty this variable
so the user doesn't get FireFox's familiar ""The page you are trying
to view contains POSTDATA" if he hits F5/Refresh.

Neither unset() nor setting the variable to nothing works:

==========
switch ($_POST['status']) {
default:
//Main screen
echo "<form method=post><input type=submit name=status
value=Print></form>";
break;

case "Print":
//SELECT, etc.

//To avoid FireFox's "The page you are trying to view contains
POSTDATA" if user hits F5

//Doesn't work unset($_POST['status']);
//Doesn't work $_POST['status']="";
break;
}
==========

Is there a way to remove this variable or set it to nothing, so that
the user is redirected to default, main screen?

Thank you.
  Réponse avec citation
Vieux 12/02/2008, 11h47   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Emptying $_POST?

On Tue, 12 Feb 2008 12:34:00 +0100, Gilles Ganault <nospam@nospam.com>
wrote:

> Hello
>
> I use a POST variable named "status" to show different screens while
> keeping everything in the same script.
>
> The problem is that in the Print screen, I need to empty this variable
> so the user doesn't get FireFox's familiar ""The page you are trying
> to view contains POSTDATA" if he hits F5/Refresh.
>
> Neither unset() nor setting the variable to nothing works:
>
> ==========
> switch ($_POST['status']) {
> default:
> //Main screen
> echo "<form method=post><input type=submit name=status
> value=Print></form>";
> break;
>
> case "Print":
> //SELECT, etc.
>
> //To avoid FireFox's "The page you are trying to view contains
> POSTDATA" if user hits F5
>
> //Doesn't work unset($_POST['status']);
> //Doesn't work $_POST['status']="";
> break;
> }
> ==========
>
> Is there a way to remove this variable or set it to nothing, so that
> the user is redirected to default, main screen?


Default flow for emptying POST/not having to deal with 'send postdata
again?' messages:

1. Set up the form to post to a script almost solely dedicated to process
that (or also other) forms.
2. Process the form, do actions, perhaps store some data in a session.
3. Instead of output/a page, send the user a header() redirect
(header('Location: http://example.com/thankyou') for instance.
4. The UA/browser of the user goes to the page desired, with a GET
request, so will receive no prompt on reload. Possibly show some variables
from the session if the user has to be informed of something/has requested
custom data.
--
Rik Wasmus
  Réponse avec citation
Vieux 12/02/2008, 13h00   #3
Gilles Ganault
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Emptying $_POST?

On Tue, 12 Feb 2008 12:47:10 +0100, "Rik Wasmus"
<luiheidsgoeroe@hotmail.com> wrote:
>Default flow for emptying POST/not having to deal with 'send postdata
>again?' messages:


Thanks for the tip, but apparently, there's no way to use POST to pass
data (I'd rather keep the URL clean of any variable). Header() will
return the user to the main page. And I'd prefer to keep all the code
in a single file/page, hence the use of "status" to know where I am.

Too bad, but it was just a minor thing. I asked just in case there
were a way to keep the user in the Print page while removing FFox's
page.

Thanks.
  Réponse avec citation
Vieux 12/02/2008, 13h26   #4
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Emptying $_POST?

On Tue, 12 Feb 2008 14:00:14 +0100, Gilles Ganault <nospam@nospam.com>
wrote:

> On Tue, 12 Feb 2008 12:47:10 +0100, "Rik Wasmus"
> <luiheidsgoeroe@hotmail.com> wrote:
>> Default flow for emptying POST/not having to deal with 'send postdata
>> again?' messages:

>
> Thanks for the tip, but apparently, there's no way to use POST to pass
> data (I'd rather keep the URL clean of any variable). Header() will
> return the user to the main page. And I'd prefer to keep all the code
> in a single file/page, hence the use of "status" to know where I am.
>
> Too bad, but it was just a minor thing. I asked just in case there
> were a way to keep the user in the Print page while removing FFox's
> page.


It is perfectly possible, just start a session, store variables in it on a
post, display (and possibly unset session variables) depending on
variables available in the session. There's no good reason a page can't
redirect to itself.
--
Rik Wasmus
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h54.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09146 seconds with 12 queries