?
Solved

<?PHP_SELF>

Posted on 2003-02-20
9
Medium Priority
?
747 Views
Last Modified: 2013-12-13
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
Comment
Question by:j1mlondon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:us111
ID: 7987656
which php version ?
try $_SERVER["PHP_SELF"]
0
 
LVL 6

Expert Comment

by:carchitect
ID: 7991792
yes which version you are using...
0
 
LVL 1

Accepted Solution

by:
s-maxim earned 300 total points
ID: 7999371

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:KC_Speedball
ID: 8004622
you have enabled parsing html-files by php or your file must be an php-file (ie. myfile.php)
0
 

Expert Comment

by:hitting_30_hard
ID: 8010073
OK why not just leave the action value blank.

the form should submit to itself

0
 
LVL 3

Expert Comment

by:KarveR
ID: 8018860
<FORM METHOD="GET" ACTION="<? $_SERVER[PHP_SELF] ?>"> should work fine , removed a surplus = tho :-)
0
 

Expert Comment

by:HitByASquirrel
ID: 8050045
try <? echo $PHP_SELF; ?>

I use that all the time
0
 

Expert Comment

by:EricJr
ID: 8362973
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
 

Expert Comment

by:mickoz
ID: 8879355
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question