Re: Page name for form submit: REQUEST_URI or SCRIPT_NAME

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

 



At 6:59 PM +0200 12/28/08, Dotan Cohen wrote:
2008/12/28 tedd <tedd.sperling@xxxxxxxxx>:
 Dotan:

 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,

 tedd


Thanks, 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


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.com

--
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