[SOLVED]How do I not use register_globals?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Locust
Forum Commoner
Posts: 31
Joined: Sat Jul 22, 2006 10:26 am

[SOLVED]How do I not use register_globals?

Post by Locust »

I'm quite used to using register globals. Often having links such as index.php?action=logout

I mainly like this because you can perform many actions without having to leave the page you're on (i.e. having to go to logout.php)

Should I be doing something else? Is there a better way without having to go to other pages?
Last edited by Locust on Fri Aug 04, 2006 12:12 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_GET['action']
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You can access the variables in the URL with:

Code: Select all

$VariableName = $_GET['VariableName'];
If that is what your asking. Also look at $_POST
Locust
Forum Commoner
Posts: 31
Joined: Sat Jul 22, 2006 10:26 am

Post by Locust »

I use $_POST with all my forms and never really used $_GET because I didn't see a need for it... now I do :) Thanks guys.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

http://example.com/index.php?this=that& ... =other_one

Code: Select all

var_dump($_GET);
Will give you:

Code: Select all

array(3) {
  ["this"]=>
  string(4) "that"
  ["lets_not"]=>
  string(6) "forget"
  ["the"]=>
  string(9) "other_one"
}
The same will apply with your forms, which can be accessed via $_POST. Check out the following pages at php.net for further knowledge.

http://php.net/manual/en/language.varia ... efined.php
http://php.net/register_globals



... bah, too slow... :oops:
Post Reply