Navid,

$SCRIPT_NAME is sometimes a safer alternative than $PHP_SELF.

The difference is that $PHP_SELF includes $PATH_INFO while $SCRIPT_NAME is
just the name of the actual script running.
http://www.php.net/manual/en/language.variables.predefined.php

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

George

Navid Yar wrote:

> Simply, to send a form to itself, you can use a special variable called
> $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 same
> script/file. This code is not very useful at all, but it gets the point
> 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 wanted
> 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 on
> 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 be
> 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 (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to