Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with $PHP_SELF on WINNT4/Apache2.0.40 2

Status
Not open for further replies.

aspx

Programmer
Jul 25, 2002
52
BG
Hi!
What I want is simply to pass variable to the same page.
My code looks like:
<?php
If (isset($submit))
{
echo &quot;You clicked here&quot;;
}
else
{
?>
<form method=post action=&quot;<?=$PHP_SELF?>&quot;>
<input type=submit name=&quot;submit&quot; value=&quot;submit&quot;>
</form>
<?
}
?>

But I think $PHP_SELF doesn't work correct on Win32, besause I get Error404 :(.
Any suggestions...
Thanx in advance!
 
What is the value of $PHP_SELF in that script? ______________________________________________________________________
TANSTAAFL!
 
Sorry, I'm new in PHP. I've copied that example from one book about PHP...All I wanted to do was to pass variable to the same page.
You mean that to $PHP_SELF must set some value before using it...I think that the variable $PHP_SELF get the value automatically from PHP-Environment.
 
No, $PHP_SELF will be automatically set by the PHP engine.

I don’t have any experience with PHP on Win32. What I am saying is that PHP may be setting the value to something you can’t use without modification.

To painfully clarify my original question, when you print $PHP_SELF to the web page, to what value has PHP set the variable in that script?

______________________________________________________________________
TANSTAAFL!
 
If I put
print $PHP_SELF;
inside the script, then Error appear (undefined variable PHP_SELF)- I use PHP4.2.2.
If I put inside the script
phpinfo();
then in the list of PHP-Variables there was no such variable as PHP_SELF, but $_Server[&quot;PHP_SELF&quot;] and it returned /test.php (the name of file where is the script)...
 
I suspect you have register_globals turned off in php.ini

Use $_SERVER[”PHP_SELF”] (which is recommended) or turn on register_globals. ______________________________________________________________________
TANSTAAFL!
 
I used $_SERVER[&quot;PHP_SELF&quot;] - there were no errors, but there were no results, too. I mean even if I clicked on button - again the button appeared (instea of message &quot;You clicked here!&quot;) - I don't know why...
After changing the php.ini-directive &quot;Register globals&quot; to &quot;On&quot; - the script started to work correctly!!!
Thanx mate (for your help and patience)!
 
The reason it didn't work at first was because you have
Code:
if (isset($submit))
which should read
Code:
if (isset($_POST['submit']))
when register_globals is off. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top