Can anybody explain why php behaves inconsistently?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
litarena
Forum Newbie
Posts: 14
Joined: Tue Sep 01, 2009 3:39 am

Can anybody explain why php behaves inconsistently?

Post 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>
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Can anybody explain why php behaves inconsistently?

Post 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?
litarena
Forum Newbie
Posts: 14
Joined: Tue Sep 01, 2009 3:39 am

Re: Can anybody explain why php behaves inconsistently?

Post 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
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Can anybody explain why php behaves inconsistently?

Post by Darhazer »

$_POST variable exist as of PHP 4.1
In 4.0, this variable is called $HTTP_POST_VARS
litarena
Forum Newbie
Posts: 14
Joined: Tue Sep 01, 2009 3:39 am

Re: Can anybody explain why php behaves inconsistently?

Post by litarena »

Thanks, Darhazer.
Post Reply