Jump to content

[SOLVED] I upgraded from Php4 to 5 and now my site doesn't work.


Recommended Posts

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.

 

 

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.

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!

 

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.

 

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.

 

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.