?
Solved

Problem with urldecode().

Posted on 2003-03-23
6
Medium Priority
?
464 Views
Last Modified: 2008-02-01
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
Comment
Question by:plastk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:Kriek
ID: 8192379
The example above from the PHP manual works fine.
Using Microsoft Internet Explorer 6.0 and PHP 4.3
0
 
LVL 1

Accepted Solution

by:
Kriek earned 300 total points
ID: 8192398
Try using $_GET

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

echo "$var1 $var2";
?>
0
 
LVL 4

Expert Comment

by:girish_nair
ID: 8192543
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
 

Expert Comment

by:dmasque
ID: 8218053
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
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 11942490
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question