Web Hosting Forum | Lunarpages
News: October 6, 2008 - Submit Your Site for the October 2008 Site of the Month!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 11, 2008, 12:25:12 PM


Login with username, password and session length


Pages: 1 [2]   Go Down
  Print  
Author Topic: PHP and Register Global Variables  (Read 6302 times)
StonedRoses
Spaceship Navigator
*****
Offline Offline

Posts: 94



WWW
« Reply #15 on: March 29, 2008, 08:30:38 AM »

Thanks alot scanman that clears it up alot, but one final question. If i aquire my UQS vars using _REQUEST, will the end user still be able to change the value in the URL and have it take effect? Or will it call the origional value given to it by the forwarding page?

Sorry if im being a pain the lower back, ide just like to clear all this up and start ammending codes before php 6 gets here.
Logged

scanman20
Master Jedi
*****
Offline Offline

Posts: 1251



WWW
« Reply #16 on: March 29, 2008, 11:35:40 AM »

Yes, anything passed in the URL can be obviously altered which is why you should always check the data you receive (validation). The real issue with using register globals is that it is a very easy way for unscrupulous people to change your code. Never rely on receiving what you expect...check for it and discard anything that doesn't fit.
Logged

Even a broken clock is right twice a day.
NotOneBit.com
MCSE - MCSA - MCP
StonedRoses
Spaceship Navigator
*****
Offline Offline

Posts: 94



WWW
« Reply #17 on: March 29, 2008, 04:22:13 PM »

Thankyou for the advice, i have allways validated my vars from UQS. But now im more confused than ever, if people can still change the URL vars, why is php being changed so i have to call it with _REQUEST. It seems to me to be the same, and therefor surely the same old security issues will still apply. (people modding the vars for their own evil ends)
 Confused
Logged

MrPhil
Quantum Encyclopedia Writer
*****
Offline Offline

Posts: 3391



« Reply #18 on: March 29, 2008, 05:59:30 PM »

The elimination of register global variables reduces the chance of malicious users "leaking in" variables that have nasty content. Now you have to explicitly import these variables with $_GET, $_POST, or $_REQUEST, which cuts the chances that you've forgotten to give valid default values before importing the actual value (if any) with $_REQUEST, etc. Of course, you still should validate a variable's data before making use of it, to prevent injection attacks and the like. It doesn't matter how a variable used in your code arrived (explicitly via $_REQUEST, or implicitly via register global variables) if it contains bogus content. Turning off register globals simply forces you to take an extra step and be a little more careful in your code design, so that you can't overlook setting your variables along any possible code path.
Logged

Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM