Page 1 of 1

Value for action in form

Posted: Fri Sep 05, 2008 6:10 am
by treesa
Hi,

Is there any difference between these 2 in php?

1. <form action="" method="post" form>
2. <form action="$_SERVER["php_self"]" method="post" form>


In both the cases ,the form calls the same form itself.is there any difference between the 2?
thanks for any help

Re: Value for action in form

Posted: Fri Sep 05, 2008 6:20 am
by jayshields
$_SERVER['PHP_SELF'] returns...
PHP Manual wrote:The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.
Whereas, as far as I know, a blank action attribute is the same as the attribute being set to "#".

In most cases, both of your examples will result in the same thing.

As a side note, you don't need to have "form" after the method attribute.