j1mlondon
asked on
<?PHP_SELF>
Hello,
I am trying to use PHP_SELF
but it doesnt work.
If I run phpinfo()
I can see an item for PHP_SELF
but when I use php_self in a form it doesnt post to itself properly.
Do I have to edit anything in php.ini to get PHP_SELF working properly???
The error is ...404 Object not found !!!!
The code is.... (sample)
<HTML>
<?php
do something here if submitted;
?>
...
...
<FORM METHOD="GET" ACTION="<?=$PHP_SELF?>"> <?php #changed this line ?>
Where do you want to go on holiday?
<BR>
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Prague">
Prague
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Barcelona">
Barcelona
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Vienna">
Vienna
<BR>
<BR>
What grade of hotel do you want to stay at?
<BR>
<BR>
<INPUT NAME="Grade" TYPE="Radio" VALUE="Three">
Three Star
<BR>
<INPUT NAME="Grade" TYPE="Radio" VALUE="Four">
Four Star
<BR>
<BR>
<INPUT TYPE="submit" name="submit" value="Enter"> <?php #changed this line ?>
</FORM>
<?php
# BREAK BACK INTO PHP HERE TO CLOSE THE ELSE STATEMENT
}
?>
</BODY>
</HTML>
I am trying to use PHP_SELF
but it doesnt work.
If I run phpinfo()
I can see an item for PHP_SELF
but when I use php_self in a form it doesnt post to itself properly.
Do I have to edit anything in php.ini to get PHP_SELF working properly???
The error is ...404 Object not found !!!!
The code is.... (sample)
<HTML>
<?php
do something here if submitted;
?>
...
...
<FORM METHOD="GET" ACTION="<?=$PHP_SELF?>"> <?php #changed this line ?>
Where do you want to go on holiday?
<BR>
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Prague">
Prague
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Barcelona">
Barcelona
<BR>
<INPUT NAME="Destination" TYPE="Radio" VALUE="Vienna">
Vienna
<BR>
<BR>
What grade of hotel do you want to stay at?
<BR>
<BR>
<INPUT NAME="Grade" TYPE="Radio" VALUE="Three">
Three Star
<BR>
<INPUT NAME="Grade" TYPE="Radio" VALUE="Four">
Four Star
<BR>
<BR>
<INPUT TYPE="submit" name="submit" value="Enter"> <?php #changed this line ?>
</FORM>
<?php
# BREAK BACK INTO PHP HERE TO CLOSE THE ELSE STATEMENT
}
?>
</BODY>
</HTML>
yes which version you are using...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you have enabled parsing html-files by php or your file must be an php-file (ie. myfile.php)
OK why not just leave the action value blank.
the form should submit to itself
the form should submit to itself
<FORM METHOD="GET" ACTION="<? $_SERVER[PHP_SELF] ?>"> should work fine , removed a surplus = tho :-)
try <? echo $PHP_SELF; ?>
I use that all the time
I use that all the time
I'm with the rest, $_SERVER['PHP_SELF'] should work instead.
To get $PHP_SELF to work, set "register_globals = ON", in your PHP.ini (in winnt of windows directory)
Cheers
To get $PHP_SELF to work, set "register_globals = ON", in your PHP.ini (in winnt of windows directory)
Cheers
hitting_30_hard - I have not tested this with every server, but I am currently doing ASP developpement and I noticed if you submit to a folder without specifying the files it can lead to problem, therefore if you put a form in a default file, let's say index.php and someone go to www.yoursite.com/blah/
this will load index.php, but if you submit it to "" it will submit to /blah/ and not the actual file... and that can lead to problem... I have not studied the whole case or if there was standard about submitting with POST especially, but that could be a reason why not to do it from what I noticed... but like I undermeant, it could have something to do with the server you are using and how it handle request...
this will load index.php, but if you submit it to "" it will submit to /blah/ and not the actual file... and that can lead to problem... I have not studied the whole case or if there was standard about submitting with POST especially, but that could be a reason why not to do it from what I noticed... but like I undermeant, it could have something to do with the server you are using and how it handle request...
try $_SERVER["PHP_SELF"]