Jump to content

Undefined Variables. Problems with upgrade from a php3 and 4 site to php 5


TecTao

Recommended Posts

I'm confused on a number of different levels regarding an upgrade a client asked me to do on his site which I believe part may have been written back in php3 and definitely php4.

 

The entire site has been written using sessions variables passing them with the old register globals on.  I've gone through the site and replaced basic things like <? to <?php and others.

 

What I've discovered is that variables like username had to be passed by $_POST and $_GET to get things limping along.

 

I'm now working in an admin area, error reporting turned on, and I'm finding a number of variables that are undefined.  the code says

if ($mode == "new")

 

But I can not find the variable $mode.  I have done a complete site search for the variable $mode and can't locate a thing.

 

So i'm confused how the previous developer wrote this and how these variables are defined.

 

Thanks for all help.

Link to comment
Share on other sites

But I can not find the variable $mode.  I have done a complete site search for the variable $mode and can't locate a thing.

 

So i'm confused how the previous developer wrote this and how these variables are defined.

 

He probably wrote it with register_globals turned on, which is a security risk and has been defaulted to off since php 4. Basically that takes GET / SESSION / POST / COOKIE data and converts it to a variable, so $mode was probably inside one of those. To fix it, you just need to figure out where it was coming from and do something like: 

 

if ($_GET['mode'] == "new")

Link to comment
Share on other sites

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.