Undefined variable passing vars via URL locally

Undefined variable passing vars via URL locally

am 18.07.2007 11:53:42 von Bob Bruyn

I've recently installed Apache 2 and php 5.2 on my WIndows XP
machine. Everything is up and running.

I'm passing some vars via the URL. It works fine online:
http://www.torusdesign.nl/spry/test.php?folder=schilderijen/ vrij_werk&navColor=SchilderijenNAV

This is the code:



The problem is that when I test it locally I get an error that the
variable in undefined.
Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
\test.php on line 14
Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
\test.php on line 15
Notice: Undefined variable: navColor in F:\WEBSERVER\Apache2\htdocs
\sonja\test.php on line 32

Can someone please help me out. Is there something wrong with my local
php configuration?

PS. You'll notice the Hello World at the top. That does work locally.
(if that's any help)


--


*******************

Bob Bruyn
Torus Design
Argonautenweg 45
3054 RP Rotterdam
010-4184349
http://www.torusdesign.nl

Re: Undefined variable passing vars via URL locally

am 18.07.2007 12:04:14 von Harrie Verveer

Hi Bob,

this means that the 'register globals' setting is 'off', which is a good
thing. Using variables the way you do in the example (possible when
register globals is 'on') can cause serious security issues (because you
can set any PHP variable through the get/post-vars - which might change
the behaviour of your script).

The proper (and far more secure) way is to use the $_GET superglobal or
$_REQUEST superglobal:



or:

$folder = $_GET['folder'];
$navColor = $_GET['navColor'];

echo $folder;
echo $navColor;
?>

or something like that :)

More info:
http://www.php.net/register_globals

Kind regards,

Harrie Verveer
---
http://www.ibuildings.nl/blog/authors/Harrie-Verveer


Bob Bruyn wrote:
> I've recently installed Apache 2 and php 5.2 on my WIndows XP
> machine. Everything is up and running.
>
> I'm passing some vars via the URL. It works fine online:
> http://www.torusdesign.nl/spry/test.php?folder=schilderijen/ vrij_werk&navColor=SchilderijenNAV
>
> This is the code:
>
>
>
> The problem is that when I test it locally I get an error that the
> variable in undefined.
> Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
> \test.php on line 14
> Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
> \test.php on line 15
> Notice: Undefined variable: navColor in F:\WEBSERVER\Apache2\htdocs
> \sonja\test.php on line 32
>
> Can someone please help me out. Is there something wrong with my local
> php configuration?
>
> PS. You'll notice the Hello World at the top. That does work locally.
> (if that's any help)
>
>

Re: Undefined variable passing vars via URL locally

am 18.07.2007 12:10:00 von Bob Bruyn

Brilliant. I had actually turner 'register globals' on but that didn't seem
to help.
But your solution

worked perfect.

Thanks!
--


*******************

Bob Bruyn
Torus Design
Argonautenweg 45
3054 RP Rotterdam
010-4184349
http://www.torusdesign.nl
"Harrie Verveer"
wrote in
message news:a-2dnW-q5r4xeADbRVnyiAA@zeelandnet.nl...
> Hi Bob,
>
> this means that the 'register globals' setting is 'off', which is a good
> thing. Using variables the way you do in the example (possible when
> register globals is 'on') can cause serious security issues (because you
> can set any PHP variable through the get/post-vars - which might change
> the behaviour of your script).
>
> The proper (and far more secure) way is to use the $_GET superglobal or
> $_REQUEST superglobal:
>
>
>
> or:
>
> > $folder = $_GET['folder'];
> $navColor = $_GET['navColor'];
>
> echo $folder;
> echo $navColor;
> ?>
>
> or something like that :)
>
> More info:
> http://www.php.net/register_globals
>
> Kind regards,
>
> Harrie Verveer
> ---
> http://www.ibuildings.nl/blog/authors/Harrie-Verveer
>
>
> Bob Bruyn wrote:
>> I've recently installed Apache 2 and php 5.2 on my WIndows XP
>> machine. Everything is up and running.
>>
>> I'm passing some vars via the URL. It works fine online:
>> http://www.torusdesign.nl/spry/test.php?folder=schilderijen/ vrij_werk&navColor=SchilderijenNAV
>>
>> This is the code:
>>
>>
>>
>> The problem is that when I test it locally I get an error that the
>> variable in undefined.
>> Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
>> \test.php on line 14
>> Notice: Undefined variable: folder in F:\WEBSERVER\Apache2\htdocs\sonja
>> \test.php on line 15
>> Notice: Undefined variable: navColor in F:\WEBSERVER\Apache2\htdocs
>> \sonja\test.php on line 32
>>
>> Can someone please help me out. Is there something wrong with my local
>> php configuration?
>>
>> PS. You'll notice the Hello World at the top. That does work locally.
>> (if that's any help)
>>