Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with urldecode function

Status
Not open for further replies.

rjseals

Technical User
Nov 25, 2002
63
US
Hi,
I am kind of new to php and am trying to use the urlencode and urldecode functions. I think I got the urlencode function to work but I am having trouble getting the urldecode function to work. I am basically trying to put the sections from the url into variables. This is what I have so far.

php:

page1.php
//connect to database, sql query etc
for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
{
$phone=$row[0];
$email=$row[1];
$first_name=$row[2];
$last_name =$row[3];



$link = "$first_name+$last_name+$phone+$email";

echo '<a href=&quot;page2.php?foo=', rawurlencod($link), '&quot;>Edit Record</a>';

{
?>


This returns the url

'

I am assuming that you use the urldecode to break this back down but am confused when I read the php manual about urldecode. I have also searched online for examples without any luck. I have also done some research on parse_url but dont think that will work in this case.

Like I said what I am trying to do is to break down the url values and put them into variables on page2.php. The reason I am doing this this way is because I want the option of modifying a record in a database and the link using the urlencode will pass the the returned values. I cant use a form because there is normally more than one record returned with my query.

If anyone could at least point me in the right direction I would appreciate it.

Thanks in advance
 
PHP will do all the decoding for you automagically. An input of the type is nothing more than a GET-method form input. The value you need will be in $_GET['foo'].

Of course, since you're talking about passing multiple data between two pages, I recommend you take a look at session variables. There is a good introduction here:
Want the best answers? Ask the best questions: TANSTAAFL!!
 
yup that will do it.
$foo=$_GET['foo'];
$foo=rawurldecode($foo);

echo $foo;

Known is handfull, Unknown is worldfull
 
i gave it as raw... because he is using rawurlencode....
:)

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top