Re: [Nolug] PHP $_POST problem

From: Petri Laihonen <pietu_at_weblizards.net>
Date: Tue, 16 Mar 2004 19:10:26 -0600 (CST)
Message-ID: <4425.68.14.52.165.1079485826.squirrel@secure.weblizards.net>

> I've got a sticky problem that I need to solve. I've just turned on
> register_globals in my PHP php.ini file, and therefore have to run my form
> variables through $_POST:
>
> Here is the script with register_globals OFF:
> http://joeykelly.net/materials.php

This did not respond.

>
> Here is the script with register_globals ON:
> http://redfishnetworks.com/~jkelly/materials.php
> Notice the huge nested array at the bottom when you click [SUBMIT]? That's

> My question: What am I doing wrong? I suspect that I'm having trouble with
> nested arrays, etc.. The thing that bothers me is that the data is
> available

Have you tried reading your array values back to simple variables?

<?php
while(list($var,$val) = each($_REQUEST)) {
        $invals .= $var . "=" . $val . "&";
}
$invals = substr_replace($invals, "", -1); // removes the last "&" sign.
echo $invals;
?>

You can also create $var <-> $val pairs and separate them with ";" instead
of "&". and naturally add "$" to the front of the $var. Then you can just
do eval($invals, ";") and all detected variables with values are there to
use.

for example:
URL: http://mydomain.com/myscript.php?myvar=myval&yourvar=yourval
(Should work with $_POST also...)

<?php
while(list($var,$val) = each($_REQUEST)) {
        $invals .= "$" . $var . "=" . $val . ";";
}
eval($invals, ";");
?>

And you should have all posted variables with the names they were posted
as if they were defined like below..
$myvar = "myval";
$yourvar = "yourval";

Okke... back to work.......

Petri

___________________
Nolug mailing list
nolug@nolug.org
Received on 03/16/04

This archive was generated by hypermail 2.2.0 : 12/19/08 EST