cformsII Support Forum
Current User: Guest *Frequently Asked Questions*
Search 
Search Forums:


 




url_encode and decode

Add a New Topic Reply to Post
Post

James Brown - Guest

7:46 pm - April 21, 2008

1

Please replace the ??? with your data!

  • Your URL: http://???
  • The browser used: IE and Firefox
  • cforms version: 7.51
  • Your Wordpress version: 2.3.3

[desc]:

This is the name of my post:
Wonder Of The World, 7 Days, Lima, Cuzco, Machu Picchu & Sacred Valley, $999.00 with Air ($200 OFF)

My form has a field called Package (cf2_field_9)

I have a link on my post <?php echo '<a href="site.com/pacakage-request/?cf2_field_9="' . urlencode("Wonder Of The World, 7 Days, Lima, Cuzco, Machu Picchu & Sacred Valley, $999.00 with Air ($200 OFF)") . '">requet package</a>'

that takes them so
http://www.site.com/package-request/?cf2_field_9=Wonder+Of+The+World%2C+7+Days%2C+Lima%2C+Cuzco%2C+Machu+Picchu+%26%23038%3B+Sacred+Valley%2C+%24999.00+with+Air+%28%24200+OFF%29

When i look at the field value (html source), it says :
Wonder Of The World, 7 Days, Lima, Cuzco, Machu Picchu &#038; Sacred Valley, 9.00 with Air (0 OFF)

How can i fix this ?
I am able to throw urlencode when they click on the link, now how do i do urldecode ?


Thanks

Oliver - Admin

8:12 pm - April 21, 2008

posts 3909

2

why do urlencode the string? try without and let the browser do it, it should work just fine.

James Brown - Guest

8:30 pm - April 21, 2008

3

If i remove the urlencode then the url becomes:

http://www.site.com/package-request/?cf2_field_9=Wonder%20Of%20The%20World,%207%20Days,%20Lima,%20Cuzco,%20Machu%20Picchu%20&%20Sacred%20Valley,%20999.00%20with%20Air%20($200%20OFF)

and the package field becomes:

Wonder Of The World, 7 Days, Lima, Cuzco, Machu Picchu


Look at the post title:
Wonder Of The World, 7 Days, Lima, Cuzco, Machu Picchu & Sacred Valley, $999.00 with Air ($200 OFF)

It has & and $ which need to be escaped somehow.

Thanks.


Oliver - Admin

9:32 pm - April 21, 2008

posts 3909

4

right, if you fully encode the string, e.g.:

Wonder+Of+The+World%2c+7+Days%2c+Lima%2c+Cuzco%2c+

Machu+Picchu+%26+Sacred+Valley%2c+%24%20999.00+

with+Air+(%24%20200+OFF)

(remove the line breaks above!)

it works, the trick: there must be a space between the $ sign and the amount, e.g. $ 200, otherwise browsers interpret it as a special character (whether or not one exists for the given code)

Reply to Post


Reply to Topic: url_encode and decode
PLEASE READ THE FAQs FIRST! THANK YOU.

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Topic Reply:

Save New PostSmileysOptions

Guest URL (required)

Math Required!
What is the sum of:
11 + 8
   

 
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell

Search