Page 1 of 1
why $PHP_SELF is not working in localhost
Posted: Thu Mar 19, 2009 11:03 am
by pankajdeoria
What is $PHP_SELF and why it is not working in Localhost? I am using wampserver software.
Thank You
Re: why $PHP_SELF is not working in localhost
Posted: Thu Mar 19, 2009 11:11 am
by Theory?
$PHP_SELF is a preset constant in the PHP compiler that basically holds the value of the document that is calling the variable. So if you use $PHP_SELF in login.php assume the value is being replaced by the compiler with login.php. As to why it's not working, are you sure you're typing it properly. It's not a stand-alone variable, it's a value that is stored in an array of $_SERVER[] values. The proper usage is something like:
Code: Select all
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>" >
//...your form here
</form>
Re: why $PHP_SELF is not working in localhost
Posted: Thu Mar 19, 2009 12:40 pm
by Jenk
Code: Select all
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
//...your form here
</form>
Small correction, added echo.
This is not an "Advanced Discussion"