RE: [PHP] Result in the same page
| From: | Cal Evans | Date: | Sun, 16 Feb 2003 21:04:29 +0000 |
| Subject: | RE: [PHP] Result in the same page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135778@lists.php.net to get a copy of this message | ||
John,
header(location:) is the way I'm doing it. I check for the Submit button, if
it was pressed and the processing succeeded, I redirect. If processing
fails (validation, error in connecting to the database, etc.) I redisplay
the same page with all the same variables that the user just input. I give
them a message telling them what went wrong and allow them to fix it.
If you find a better way, please share. It would be nice to have something
like <jsp:forward>
=C=
-----Original Message-----
From: John Hicks [mailto:johnhicks@gulfbridge.com]
Sent: Saturday, February 15, 2003 11:56 PM
To: cal@calevans.com
Subject: Re: [PHP] Result in the same page
Cal--
I just posted this reply to your reply on php.general.
--John
From: frappyjohn@netscape.net (John Hicks)
Newsgroups: php.general
Subject: Re: [PHP] Result in the same page
References: <20030118121441.36054.qmail@pb1.pair.com>
<FLEGKEMHDIDDEJOGHHNFIEMCJIAA.cal@calevans.com>
NNTP-Posting-Host: 68.165.13.138
Message-ID: <30024cc9.0302152139.177da3f6@posting.google.com>
I, too, like the idea of keeping my processing code in the same file
as the form being processed. But I'm trying to figure out how to
transfer control to the next page based on the result of the forms
processing.
In JSP, i would use <jsp:forward>, which is basically a "Go to"
command. The only reference I can find to "transfer of control" in PHP
is the header(location: ) function. But that requires a complete
server/browser/server interchange.
There must be a more direct way to transfer control in PHP. Would
someone please tell me what it is?
Thanks in advance,
Frappy
cal@calevans.com (Cal Evans) wrote in message
news:<FLEGKEMHDIDDEJOGHHNFIEMCJIAA.cal@calevans.com>...
> Yes, just user $_SERVER['PHP_SELF'] as the action of your form. This will
> cause the page to call itself. Then you can branch your processing on the
> existence of a SUBMIT button (or whatever) and handle the query.
>
> I do all my pages this way because it keeps all the code in a single page.
> It's easier for me to find it that way.
>
> =C=
>
> *
> * Cal Evans
> * Stay plugged into your audience.
> * http://www.christianperformer.com