473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

accessing $_GET implicitly

OK, here's the start of the index file I'm working on and its used for every page like so
index.php?action=register
index.php?action=logout
etc.
<?php

define ('IN_SITE', 1 );
define ('LOGGED_IN', FALSE );
$userinfo = '';

include('config.php');

$link = @mysql_connect ($DB_HOST, $DB_USER, $DB_PASS) or die ('SQL Connection troubles');
mysql_select_db ($DB_DB);

include($_SERVER['DOCUMENT_ROOT'] . "/functions.php");
if ($action != "do_login")
{
$user = $_COOKIE['user'];
$pass = $_COOKIE['pass'];
if (verifyuser('', $pass,$user) == TRUE)
Nowhere in config or functions is $action defined, so how can this work?
It works on CPanel but not in PLESK. In PLESK I added the line $action = $_GET['action'];
I thought it already had it, that got it working in PLESK aswell but some screens still don't show
so I took it out again.

Herc

Oct 19 '05 #1
2 3220
"|-|erc" <h@r.c> wrote in message
news:43***********************@authen.white.readfr eenews.net...
OK, here's the start of the index file I'm working on and its used for
every page like so
index.php?action=register
index.php?action=logout
etc.
if ($action != "do_login")
{
$user = $_COOKIE['user'];
$pass = $_COOKIE['pass'];
if (verifyuser('', $pass,$user) == TRUE)
Nowhere in config or functions is $action defined, so how can this work?


There is a PHP configuration directive (i.e. something you put in the config
file) "register_globals" which allows any or all entities from forms (GET
and POST), cookies, server internals and the local environment to appear to
scripts just as if they're day-to-day script variables. As of PHP 4.2.0 this
defaults to "off", though clearly you can turn it on if you so desire.

I don't personally like implicit variable definitions like this, because
variables can trample over one another and cause confusion (or even security
problems) when what you thought was a local variable turns out to be a field
from a form, or vice versa. The developers of PHP clearly don't like it
either, as they've taken the conscious decision to turn it off.

For a developer, a nicer way to go is the import_request_variables()
function, which you can drop into your scripts to register form variables
yourself. import_request_variables() allows you to prefix the variable names
with a text string to allow you to distinguish them from other variables -
so, for instance, everything I write has a import_request_variables() call
that makes all my form variables appear as $form_blah, thus guaranteeing I'm
not going to trample over local stuff by mistake.

HTH,

David C
Oct 19 '05 #2
"David Cartwright" <ds**********@hotmail.com> wrote in ...
: "|-|erc" <h@r.c> wrote in message
: > OK, here's the start of the index file I'm working on and its used for
: > every page like so
: > index.php?action=register
: > index.php?action=logout
: > etc.
: > if ($action != "do_login")
: > {
: > $user = $_COOKIE['user'];
: > $pass = $_COOKIE['pass'];
: > if (verifyuser('', $pass,$user) == TRUE)
: > Nowhere in config or functions is $action defined, so how can this work?
:
: There is a PHP configuration directive (i.e. something you put in the config
: file) "register_globals" which allows any or all entities from forms (GET
: and POST), cookies, server internals and the local environment to appear to
: scripts just as if they're day-to-day script variables. As of PHP 4.2.0 this
: defaults to "off", though clearly you can turn it on if you so desire.
:
: I don't personally like implicit variable definitions like this, because
: variables can trample over one another and cause confusion (or even security
: problems) when what you thought was a local variable turns out to be a field
: from a form, or vice versa. The developers of PHP clearly don't like it
: either, as they've taken the conscious decision to turn it off.
:
: For a developer, a nicer way to go is the import_request_variables()
: function, which you can drop into your scripts to register form variables
: yourself. import_request_variables() allows you to prefix the variable names
: with a text string to allow you to distinguish them from other variables -
: so, for instance, everything I write has a import_request_variables() call
: that makes all my form variables appear as $form_blah, thus guaranteeing I'm
: not going to trample over local stuff by mistake.
:

great thanks, I just used import_request_variables("gpc"); and all the pages work now.
GET and POST are so simple to use anyway so I'll stick with them atleast for my own code.

Herc

Oct 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James | last post by:
Hi, I am trying to build a shopping cart for my DVD website and am having trouble reading variable over different pages. I have a page that allows the user to add things to their cart and this...
32
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at...
17
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next...
6
by: Rainman | last post by:
I'm sure there is an FAQ on this somewhere, but I couldn't find one. I'm sure a responder will clue me in. my URL is: mypage.php?var=2&var=4&var=5 print_r($_GET); gives me: 5 instead of
1
by: Greg Scharlemann | last post by:
There is probably an easy solution to this that I've overlooked somewhere... I have a main file, call it main.php, and an include file, myInclude.php. I'm accessing main.php via:...
1
by: jenson | last post by:
<?php /* * Created on Apr 13, 2007 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ require_once 'init.php'; ...
2
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
3
by: Michaelp | last post by:
Hello! I see that I can access a superglobal element using the index this way: print("<p>$_GET</p>"); //(element index without any delimiters within a double-quotation-mark-delimited string)...
5
by: Aaron Gray | last post by:
How do I access URL parameters, and ideally as an associative array ? Many thanks in adance, Aaron
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.