Value for action in form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
treesa
Forum Commoner
Posts: 29
Joined: Sun Aug 31, 2008 10:19 pm

Value for action in form

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Value for action in form

Post 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.
Post Reply