TecTao Posted September 13, 2012 Share Posted September 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/268338-undefined-variables-problems-with-upgrade-from-a-php3-and-4-site-to-php-5/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2012 Share Posted September 13, 2012 Mode could be from $_GET, $_POST, $_COOKIE, or $_SESSION. Perhaps there are urls with ?mode=new on them or a post method form that has <input type='hidden' name='mode' value='new'> Quote Link to comment https://forums.phpfreaks.com/topic/268338-undefined-variables-problems-with-upgrade-from-a-php3-and-4-site-to-php-5/#findComment-1377702 Share on other sites More sharing options...
premiso Posted September 13, 2012 Share Posted September 13, 2012 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") Quote Link to comment https://forums.phpfreaks.com/topic/268338-undefined-variables-problems-with-upgrade-from-a-php3-and-4-site-to-php-5/#findComment-1377705 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.