Page 1 of 1

Can anybody explain why php behaves inconsistently?

Posted: Tue Sep 01, 2009 4:14 am
by litarena
Can anybody explain why php behaves inconsistently with the same script and
without a config file?

I have two php configurations and neither has a php.ini config file.
(a) PHP Version 4.0.6 (FreeBSD) Apache/1.3.6
(b) PHP Version 5.3.0 (Centos) Apache/2.0.63
On both webservers I'm running exactly the same php script with no changes.
On webserver (a) when input data is entered the form is immediately cleared
and nothing else happens. (This is clearly an error)

BUT, on webserver (b) [running exactly the same script] (neither webserver
has a php.ini config file) I enter my name "Dirty Harry"

and the webserver returns:
User Has submitted the form and entered this name : Dirty Harry
You can use the following form again to enter the new name.


[Question]
Why does one webserver work properly and the other, (with the same
script,) does not?



========================================================================
script is below
========================================================================



<?php if(isset($_POST['submit'])) {
$name = $_POST['name'];
echo "User Has submitted the form and entered this name : <b>" . $name . "</b>";
echo "<br>You can use the following form again to enter the new name.";
}
?>
<HTML>
<HEAD><title>Using PHP_SELF</title></HEAD>
<BODY>
<FORM name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Enter Your Name: <input type="text" name="name"><br>
<input type="submit" name="submit" value="Submit Form"><br>
</FORM>
</BODY>
</HTML>

Re: Can anybody explain why php behaves inconsistently?

Posted: Tue Sep 01, 2009 4:25 am
by Mark Baker
litarena wrote:Can anybody explain why php behaves inconsistently with the same script and
without a config file?
Because some defaults, such as register_globals, have changed between the different versions of PHP.
Why are you running without php.ini files anyway?

Re: Can anybody explain why php behaves inconsistently?

Posted: Tue Sep 01, 2009 5:06 am
by litarena
(i)
Because webserver (a) formerly had an ini file and (b) did not.

register_globals = On in (a)


(ii)
now both webservers have exactly the same ini file (register_globals = On) and the webservers still behave inconsistently. (b) works with the script and (a) does not.


Could anybody explain what the role of the cgi.fix_pathinfo=1 variable is (in php 4.0.6) when
when using the $_SERVER['PHP_SELF'] directive?
I have cgi.fix_pathinfo=1 enabled, however the script still does not function correctly on php 4.0.6

Re: Can anybody explain why php behaves inconsistently?

Posted: Tue Sep 01, 2009 2:36 pm
by Darhazer
$_POST variable exist as of PHP 4.1
In 4.0, this variable is called $HTTP_POST_VARS

Re: Can anybody explain why php behaves inconsistently?

Posted: Tue Sep 01, 2009 3:56 pm
by litarena
Thanks, Darhazer.