Good point. I actually like your idea a lot. I have never thought about

You also mentioned using "$PATH_INFO to implement elegant (and
search-engine safe) urls..." below. Can you give me a couple of examples
of how I might do this? I always hated the GET strings at the end of the
url. Sometimes I redirect a user to the same page two times just to get
rid of the trailing GET string. I know that's a bad way of doing it, but
it was a temporary thing until I could find a way around it. I would
really appreciate your help on this one. Thanks...


-----Original Message-----
From: George Whiffen [mailto:[EMAIL PROTECTED]] 
Sent: Monday, February 18, 2002 7:09 AM
To: Navid Yar
Subject: Re: [PHP] form submission error trapping


$SCRIPT_NAME is sometimes a safer alternative than $PHP_SELF.

The difference is that $PHP_SELF includes $PATH_INFO while $SCRIPT_NAME
just the name of the actual script running.

This becomes particularly important if you use $PATH_INFO to implement
elegant (and search-engine safe) urls e.g. /search/products/myproduct
than /search.php?category=products&key=myproduct.


Navid Yar wrote:

> Simply, to send a form to itself, you can use a special variable
> $PHP_SELF. Here's an example of how to use it:
> if ($somevalue) {
>    header("Location: $PHP_SELF");
> } else {
>    execute some other code...
> }
> Here, if $somevalue holds true, it will call itself and reload the
> script/file. This code is not very useful at all, but it gets the
> across. If you wanted to pass GET variables to this, then you could
> easily say:
> header("Location: $PHP_SELF?var=value&var2=value2&var3=value3");
> ...and so on. You can also use this approach with Sessions if you
> to turn the values back over to the form page, assuming you had two
> pages: one for the form, and one for form checking and entry into a
> database. There are several ways to check forms, whether you want it
> one page or span it out to several pages. You just need to be creative
> in what tools are avaiable to you. Here is an example of how you can
> pass session values:
> header("Location: some_file.php?<?=SID?>");
> Here, whatever variables you've registered in session_register() will
> passed to the php page you specify, in this case some_file.php. Hope
> this helps. Have fun, and happy coding.  :)

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to