Retreiving data with register_globals=off

Posted on 2003-12-03
Last Modified: 2006-11-17
My code was working fine until I upgraded to a newer PHP version, now I'm having major problems.

I have an index page, which takes a var like this: ""

I used to use this simple code:


to extract the page number, but this no longer works, so can someone please tell me what I should be using.

I know I can turn on register_globals but i dont want to...

Question by:rjdown
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 9867008
You don't need to turn on register_globals, but you do need to refer to your variable differently.  Try using this instead


I hope this helps :)

Author Comment

ID: 9867112
Thanks for quick reply but still nothing...

I made a new file, test.php:

echo $page;

now if i go to this using test.php?page=23 i still get a blank page? :'(

Accepted Solution

LornaJane earned 50 total points
ID: 9867210
try this, I don't think I explained myself terribly well before:

$page = $GET['page'];
echo $page;

If you don't understand what the above code does, post back and I'll explain more clearly

Author Comment

ID: 9867586
Oops, my bad.

I had a look through the php manual and found that it should in fact be $_GET. Horrah, my code works again :D

Thanks Lorna :D


Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question