Re: Page name for form submit: REQUEST_URI or SCRIPT_NAME
| From: | tedd | Date: | Sun, 28 Dec 2008 17:21:09 +0000 |
| Subject: | Re: Page name for form submit: REQUEST_URI or SCRIPT_NAME | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285150@lists.php.net to get a copy of this message | ||
At 6:59 PM +0200 12/28/08, Dotan Cohen wrote:
2008/12/28 tedd <tedd.sperling@gmail.com>:Dotan: Sometimes the simplest is the best, but you might try this: action="<?php echo basename($_SERVER['SCRIPT_NAME']) ;?>" At least you can say it's not as simple. :-) As for saving a form locally, then you'll have to get the entire url. Here's a less than simple solution: function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } It works. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comDotan: Maybe this is too simple, but what I do is to leave the form attribute action="" blank. My understanding (may be wrong) is that forms always submit to themselves unless directed to do so otherwise. Cheers, teddThanks, Tedd. That approach seems a bit dangerous for non-standard browsers such as mobile phones and the like who's developers might not have though about it. Also, in the event that a user saves the form locally (likely in this case) I need it to have a place to go! Thanks! -- Dotan Cohen