I have a php form like this.
<form name="form1" id="mainForm" method="post"enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>">
</form
In form action I want to use page name with parameters. like house.php?p_id=10111
. But $_SERVER['PHP_SELF'] gives only the house.php
(My page full url is house.php?p_id=10111
like this) Please help me to solve this problem. thanks.
This is Perfect. try this one :)
How about leaving it empty, what is wrong with that?
Also, you can omit the action attribute and it will work as expected.
You can use an echo shortcut also instead of typing out "echo blah;" as shown below:
You can leave action blank or use this code:
Another (and in my opinion proper) method is use the
__FILE__
constant if you don't like to rely on$_SERVER
variables.About magic and predefined constants: 1, 2.
Leaving the action value blank will cause the form to post back to itself.