Closed Thread Icon

Topic awaiting preservation: _POST _GET (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12766" title="Pages that link to Topic awaiting preservation: _POST _GET (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: _POST _GET <span class="small">(Page 1 of 1)</span>\

 
lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 05-30-2003 11:24

Hello,

When the global vars are off, one has to access post variables or get variables via either $_POST or $_GET in PHP.

how can I access the variable directly through one global array instead of checking first in $_POST then in $_GET ?

Elias

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 05-30-2003 11:53

Seems like this might be what you are after:
[snip from manual]
Request variables: $_REQUEST
Note: Introduced in 4.1.0. There is no equivalent array in earlier versions.

An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.

Note: Prior to PHP 4.3.0, $_FILES information was also included into $_REQUEST.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_REQUEST; to access it within functions or methods.

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_REQUEST array. For related information, see the security chapter titled Using Register Globals. These individual globals are not autoglobals.

[end snip from manual]
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 05-30-2003 12:00

Hello,

Yes DmS, then _REQUEST is what I was after.

Thanks

Elias

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 05-30-2003 21:33

actually, I'd beat you if you used request in a project I was responsible for.

Actually,
"why can your variables come in either way? And why doesn't your code know which way it came", I'd ask you.
And then I'd probably beat you ;-)

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-31-2003 14:32

Yeah wouldn't that leave you open to people hacking your POST variables using GET?

___________________
Emps

FAQs: Emperor

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-31-2003 21:54

I've written admin code for a few sites that allow the admin to get to select entries to edit via and ahref link on one page, but also access that same admin page by filling in a form that feeds to the same script which makes some of the same variables come in either way... POST or GET depending on where they came from.

If there is an easier/better way to do this I would like to know so I can correct what I'm doing wrong.

Thanks

-Butcher-

trib
Paranoid (IV) Inmate

From: Den Haag, Netherlands
Insane since: Sep 2002

posted posted 06-03-2003 10:12

Butcher ... Look at Session Management using PHP ... you'll find chapters in every book with a title very much like that, and thats how you should be passing data around inside a single users session. The form can either post the data initially, or you can use some javascript to initialise the session variables directly from the form ...


Sessions use cookies, but there is also a way of circumventing the problem of browsers with cookies turned off. Look explanations of how to use the SESSID variable ... and here's a beaut ... HREF="nextpage.php?<?php echo strip_tags (SID)> ... does it for you.

see ... http://nl.php.net/session for more PHP manual info.


Bug-free software only exisits in two places
A programmer's mind and a salesman's lips

« BackwardsOnwards »

Show Forum Drop Down Menu