• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 750
  • Last Modified:

<?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>
0
j1mlondon
Asked:
j1mlondon
1 Solution
 
us111Commented:
which php version ?
try $_SERVER["PHP_SELF"]
0
 
carchitectCommented:
yes which version you are using...
0
 
s-maximCommented:

If PHP version is over 4.2* then you have register globals off. Whether turn them on in php.ini or refer to this variable as follows:

$_SESSION['PHP_SELF']

Actually, if I am not wrong, there is also such constant defined  PHP_SELF. so, echo PHP_SELF might also work... Though can be wrong on this last one ..
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
KC_SpeedballCommented:
you have enabled parsing html-files by php or your file must be an php-file (ie. myfile.php)
0
 
hitting_30_hardCommented:
OK why not just leave the action value blank.

the form should submit to itself

0
 
KarveRCommented:
<FORM METHOD="GET" ACTION="<? $_SERVER[PHP_SELF] ?>"> should work fine , removed a surplus = tho :-)
0
 
HitByASquirrelCommented:
try <? echo $PHP_SELF; ?>

I use that all the time
0
 
EricJrCommented:
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
0
 
mickozCommented:
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...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now