kmutz22 Posted January 8, 2009 Share Posted January 8, 2009 Well it does work a bit, but not the main bit. So this is the code for my index page: <?php require ("config.php"); include("functions.php"); if(!isset($cmd))$cmd=1; switch($cmd) { case 1:$file="mainpage.php"; break; case 2:$file="signup.php"; break; case 3:$file="viewprofile.php"; break; } include("header.php"); include($file); include("footer.php"); include("conclose.php"); Whenever I try to do any command eg: http://mysite.com/index.php?cmd=3&username=test , it just goes to the main page. It still shows that in the address bar but it displays mainpage.php. It worked perfectly before I upgraded and it's probably something really simple but I don't have a clue. ANy help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/ Share on other sites More sharing options...
premiso Posted January 8, 2009 Share Posted January 8, 2009 Register_globals is off in PHP 5 by default, so any code that used GET or POST or COOKIE or SESSION data will have to be re-written to $_GET['cmd'] etc... <?php require ("config.php"); include("functions.php"); $cmd = (isset($cmd))?$_GET['cmd']:1; switch($cmd) { case 1:$file="mainpage.php"; break; case 2:$file="signup.php"; break; case 3:$file="viewprofile.php"; break; } include("header.php"); include($file); include("footer.php"); include("conclose.php"); You will probably have to do the same thing with $username etc. Anything that comes from a query string or POST data needs to be changed like I did to $cmd. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732831 Share on other sites More sharing options...
kmutz22 Posted January 8, 2009 Author Share Posted January 8, 2009 Register_globals is off in PHP 5 by default, so any code that used GET or POST or COOKIE or SESSION data will have to be re-written to $_GET['cmd'] etc... <?php require ("config.php"); include("functions.php"); $cmd = (isset($cmd))?$_GET['cmd']:1; switch($cmd) { case 1:$file="mainpage.php"; break; case 2:$file="signup.php"; break; case 3:$file="viewprofile.php"; break; } include("header.php"); include($file); include("footer.php"); include("conclose.php"); You will probably have to do the same thing with $username etc. Anything that comes from a query string or POST data needs to be changed like I did to $cmd. Arrggh I knew that as well! Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732835 Share on other sites More sharing options...
kmutz22 Posted January 8, 2009 Author Share Posted January 8, 2009 Oh well when I try the new code, I get: Parse error: syntax error, unexpected ':' in ..... on line 4 What's going on? Sorry if its obvious, I just haven't had to do PHP for a long time. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732840 Share on other sites More sharing options...
premiso Posted January 8, 2009 Share Posted January 8, 2009 $cmd = isset($_GET['cmd'])?$_GET['cmd']:1; Not sure, replace that line though I had it wrong earlier. See if that maybe fixes the problem. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732847 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2009 Share Posted January 8, 2009 FYI: register_globals were turned off in php4.2 in the year 2002. This has nothing to do with php5, but code and programmers that did not learn and follow up to date (6 - 7 years ago now) programming practices. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732850 Share on other sites More sharing options...
kmutz22 Posted January 8, 2009 Author Share Posted January 8, 2009 Fixed, thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732858 Share on other sites More sharing options...
premiso Posted January 8, 2009 Share Posted January 8, 2009 FYI: register_globals were turned off in php4.2 in the year 2002. This has nothing to do with php5, but code and programmers that did not learn and follow up to date (6 - 7 years ago now) programming practices. Ah, server admins must have also enabled this due to that fact too, I know my server runs php 4.3, but has that enabled. So yea, whoops. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732862 Share on other sites More sharing options...
PFMaBiSmAd Posted January 8, 2009 Share Posted January 8, 2009 Slightly off topic/rant - It is unfortunate that when the huge security hole that register_globals opened up, in allowing session variables to be altered by simply supplying a GET/POST/COOKIE with the same name as a session variable, was discovered that register_globals were not permanently disabled. That might have caused at most a few thousand scripts at the time to need to be updated to work with php4.2, but that would have been preferable to the multi 100's of thousands of scripts that have been mistakenly written since then that are using register_globals and are breaking when servers are upgraded using recommended php.ini settings and will completely stop working under php6 where the underlying register_globals code has been finally removed. Quote Link to comment https://forums.phpfreaks.com/topic/140068-solved-i-upgraded-from-php4-to-5-and-now-my-site-doesnt-work/#findComment-732877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.