Jump to content

Recommended Posts

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!

 

 

Link to comment
https://forums.phpfreaks.com/topic/139890-variable-question-php4-to-php5/
Share on other sites

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

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.

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.

 

 

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.