Solved

Retreiving data with register_globals=off

Posted on 2003-12-03
4
218 Views
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: "http://www.mysite.com/index.php?page=12"

I used to use this simple code:

$HTTP_GET_VARS[$page];

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...

Thanks
0
Comment
Question by:rjdown
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:LornaJane
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

$GET['page']

I hope this helps :)
0
 
LVL 6

Author Comment

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

I made a new file, test.php:

<?php
$GET['page'];
echo $page;
?>

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

Accepted Solution

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

<?php
$page = $GET['page'];
echo $page;
?>

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

Author Comment

by:rjdown
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

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
echo button 13 47
Should you use {} for a variable in heredoc 3 27
File not deleting using unlink 6 13
Adding through query php 9 12
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now