litarena Posted September 1, 2009 Share Posted September 1, 2009 Can anybody explain why php behaves inconsistently with the same script and BOTH with and without an (*identical*) config file? And with the config variable cgi.fix_pathinfo=1 set (on both identical configs) I have two php configurations initially neither has a php.ini config file. (then in one experiment I put the same config file on both) (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> Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/ Share on other sites More sharing options...
ignace Posted September 1, 2009 Share Posted September 1, 2009 Have you tried outputting what $_POST contains on both servers after submitting the form? Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910270 Share on other sites More sharing options...
JonnoTheDev Posted September 1, 2009 Share Posted September 1, 2009 Read description http://us3.php.net/manual/en/reserved.variables.server.php Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910272 Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2009 Share Posted September 1, 2009 (edit: from the same page that neil.johnson just linked to) Changelog Version Description 4.1.0 Introduced $_SERVER that deprecated $HTTP_SERVER_VARS. What on earth are you doing using such an old version of php? Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910276 Share on other sites More sharing options...
ignace Posted September 1, 2009 Share Posted September 1, 2009 (a) PHP Version 4.0.6 (FreeBSD) Apache/1.3.6 (b) PHP Version 5.3.0 (Centos) Apache/2.0.63 Damn I need to get my eyes checked I didn't even see that at first. Upgrade server a to the version of server b and you are good to go. The reason your script on a is failing is due to the php version installed 4.0.6 $_SERVER as in $_SERVER['PHP_SELF'] was only introduced as of 4.1.0 pointed out by pfmabismad. Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910286 Share on other sites More sharing options...
litarena Posted September 1, 2009 Author Share Posted September 1, 2009 Have you tried outputting what $_POST contains on both servers after submitting the form? var_dump($_POST) on the webserver which works returns array(2) { ["name"]=> string(10) "Dirty Harry" ["submit"]=> string(11) "Submit Form" } And on the webserver which doesn't work, the same script returns: NULL Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910287 Share on other sites More sharing options...
litarena Posted September 1, 2009 Author Share Posted September 1, 2009 error_reporting(E_ALL); Warning: Undefined variable: _POST in /usr/local/apache/htdocs/HTML/PHP/PHP-tutorial/FormProcessing/self-tesstformgood.php on line 27 !!! Ha! I wanted to find out specifically why it didn't work! Now I know! Thanks guys! Link to comment https://forums.phpfreaks.com/topic/172694-solved-can-anybody-explain-why-php-behaves-inconsistently/#findComment-910305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.