cytech Posted January 7, 2009 Share Posted January 7, 2009 Hey All, I just picked up a small edit job from this guy who's admin panel didn't work, so I went in and found out that it was developed way back in the day. So all of the variables are set almost like globals. Example: $pageTitle $pageDescription Instead of $_POST['pageTitle']; $_POST['pageDescription']; Now he is currently running the latest version of php, of course nothing works becuase php5+ doesn't regonize $pageTitle as $_POST['pageTitle'], is there a quick fix to this mess? or do I need to edit each variable to make it work again?? Thanks for any advice! Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/ Share on other sites More sharing options...
rhodesa Posted January 7, 2009 Share Posted January 7, 2009 I HIGHLY recommend going through and changing the variables to their proper $_POST names. But, if you like your site being open to hacking, you can enable register globals: http://us.php.net/manual/en/ini.core.php#ini.register-globals Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731886 Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 The quick fix, which I highly do not recommend due to security issues is you can turn register_globals on in the php.ini. But yea it is better to define them at the top of the page so you know what is coming in. IE for each variable that is retrieved from post you can just put this code at the top of the page: $pageTitle = isset($_POST['pageTitle'])?$_POST['pageTitle']:null; $pageDescription = isset($_POST['pageDescription'])?$_POST['pageDescription']:null; And that is much better alternative than turning back on register_globals. Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731889 Share on other sites More sharing options...
cytech Posted January 7, 2009 Author Share Posted January 7, 2009 Thats exactly what I told the guy, that whole system is crazy, but he wants a quick fix and thats it. Thanks did the trick. Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731890 Share on other sites More sharing options...
cytech Posted January 7, 2009 Author Share Posted January 7, 2009 I actually kept globals off. One of my buddies said do extract($_POST) for the areas that need it, that did the trick. I hate working on sites like this, you want to go ahead and overhaul it but its just not in the cards so to speak haha Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731892 Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 I actually kept globals off. One of my buddies said do extract($_POST) for the areas that need it, that did the trick. I hate working on sites like this, you want to go ahead and overhaul it but its just not in the cards so to speak haha Yea extract works, but still gives the same flaw with any post variables. But it is more secure than having the cookies/session/post/get all being made into their variables. You could even use a loop in place of extract with an array of defined variables coming from the form, but yea. Another option I guess. Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731897 Share on other sites More sharing options...
cytech Posted January 7, 2009 Author Share Posted January 7, 2009 Yea, I was thinking that as well, just defining the fields in a global array and going through it, but this script is massive. I will be updating it for him later on. Quote Link to comment https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/#findComment-731910 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.