Jump to content


Photo

HTTP Post Vars into a URL


  • Please log in to reply
2 replies to this topic

#1 OsiViper

OsiViper
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 22 September 2006 - 09:08 AM

Ok quick question with some php code and i have no idea how to have it do what i want

Im retreiving these 3 vars from a previous page:

$name = $HTTP_POST_VARS['Name'];
$class = $HTTP_POST_VARS['Class'];
$level = $HTTP_POST_VARS['Level'];

Which are then emailed to me, the email contains a link to a different page what has some HTTP_GET_VARS on it

http://www.webpage.c...ss&level=$level

That all works out fine. My problem is, on the main page where people put the information in the textboxes, is some of the stuff they need to put spaces, commas, etc in, and in the email that breaks the link, how do i have it encode the url removing the spaces/commas/other symbols so it comes out as a whole link in the email?

I know this is probably pretty simple, but im still just learning PHP

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 September 2006 - 09:19 AM

Use urlencode. On the values from your form inputs.

So you'll want to do something like this:
$name = urlencode($HTTP_POST_VARS['Name']);
$class =  urlencode($HTTP_POST_VARS['Class'];)
$level =  urlencode($HTTP_POST_VARS['Level']);

When you retrieve the them from url you'll wnt to decode then with urldecode
Eg:
$name = urldecode($HTTP_GET_VARS['Name']);
$class =  urldecode($HTTP_GET_VARS['Class'];)
$level =  urldecode($HTTP_GET_VARS['Level']);


#3 OsiViper

OsiViper
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 22 September 2006 - 09:24 PM

Cool, that worked :)

Thanks a ton!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users