• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

Problem with urldecode().

I installed and configured PHP 4.3 with all default settings. For some reason this code won't work, nor will any other method pull the values out of the url.   All of them remain NULL no matter what value I give them.  The urlencod() function works perfectly fine.

URL: http://www.foo.com/test.php?var1=Hello&var2=World 

================================
<?
$var1 = urldecode($var1);
$var2 = urldecode($var2);

echo "$var1 $var2";
?>
0
plastk
Asked:
plastk
1 Solution
 
KriekCommented:
The example above from the PHP manual works fine.
Using Microsoft Internet Explorer 6.0 and PHP 4.3
0
 
KriekCommented:
Try using $_GET

<?
$var1 = urldecode($_GET['var1']);
$var2 = urldecode($_GET['var2']);

echo "$var1 $var2";
?>
0
 
girish_nairCommented:
Hi,

The default setting in the php is register_global Off, You need to turn it "On" in the php.ini  if you want to use the variables directly, else use $_GET & $_POST to access the variables in the url ...

Also see the security related aspect of turning register_global to On.
http://php.net/

Cheers,
Girish
0
 
dmasqueCommented:
Slight addition guys:
urldecode is unnecessary, PHP does it for you ;)

also either turn register_global on in php.ini
or just put <?  import_request_variables('g') ?>

This is a kewl little function as you can get away virtually a specific register_globals without giving away too much security by prefixing all "imported" variables with your own prefix.

Ex: http://mydom.com/index.php?var1=1&var2=2
where index contains
<? import_request_variables('g','myapp_') ?>
will import only the two get vars under the names
$myapp_var1 and $myapp_var2

well I like it :)
0
 
snoyes_jwCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: Kriek {http:#8192398}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

snoyes_jw
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now