PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 1st, 2007, 02:15 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 16
$id Vs. $_GET['id']

Hello,

I created a lot of PHP pages where i am accessing variable's passed from other pages (using GET and POST) using just the variable name (e.g. $id).

Now, the server was reformatted and for some reason this works no more. I have to replace $id with $_GET['id'] and so on. Is there anyway i can avoid doing this and access them with thier name again.

Thanks
Neville

Reply With Quote
  #2  
Old March 1st, 2007, 02:53 PM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Put this in a common include in the beginning of your code:
PHP Code:
foreach ($_GET as $key => $var) {
$
$key $var;
}

foreach (
$_POST as $key => $var) {
$
$key $var;


I will refrain from a safety first rant, but I would advise you to update your code.
__________________
One World... Humanetainit | Program secure

Last edited by Humanetainit : March 1st, 2007 at 02:55 PM.

Reply With Quote
  #3  
Old March 1st, 2007, 03:36 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 13
globals

Quote:
Originally Posted by nevillemehta
the server was reformatted and for some reason
My bet is that if you look at a phpinfo() file you will find that the host has turned off register globals. This is a very good thing as they can be a huge security risk. Especially the way you are using them. If you are passing variables around this way be certain that you are sanitizing them before using the values for anything that's crucial or might introduce a security hole.
To repeat Humanetainit's comment, UPDATE your code.

Last edited by Mittineague : March 1st, 2007 at 03:39 PM.

Reply With Quote
  #4  
Old April 26th, 2007, 10:08 AM
HalitYesil HalitYesil is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 4 HalitYesil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 54 sec
Reputation Power: 0
PHP Code:
if(!(bool)ini_get('register_globals')) ini_set('register_globals''on'); 


this code your script include top...

yourscript.php?asd=test
out put

echo $asd;

--- test


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > $id Vs. $_GET['id']


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap