Re: Page name for form submit: REQUEST_URI or SCRIPT_NAME

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 27, 2008 at 12:31, Dotan Cohen <dotancohen@xxxxxxxxx> wrote:
> Is there a compelling reason to use either REQUEST_URI or SCRIPT_NAME
> in the action of a form that I want to submit to the same URL that it
> came from (the script parses whether or not there is a Submit to know
> if it should display the form or the results). I need a portable
> solution, that is why I am not hardcoding it. Also, the users _may_
> save the form to their hard drives, so simply leaving the action blank
> will not do.
>
> I know that REQUEST_URI includes the ?variable=value string and that
> SCRIPT_NAME does not. This form does not depend upon get variables, so
> this should never be an issue, but I ask here anyway to know if there
> are other differences that I did not account for.

    Happy Chanukah, Dotan!

    For portability's sake, especially if you anticipate users saving
the form to their local systems, I would recommend:

<?php
$action = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
?>
<form method="<?php echo $action; ?>">

    If you use REQUEST_URI and the form is on a page not called
directly (for example, on index.php and called only by directory; a
mod_rewrite /contact page; etc.), using REQUEST_URI gives the actual
request, where PHP_SELF gives the actual file.

-- 
</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux