Jump to content

HTTP Post Vars into a URL


OsiViper

Recommended Posts

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.cc/test.php?name=$name&class=$class&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
Link to comment
Share on other sites

Use [url=http://php.net/urlencode]urlencode[/url]. On the values from your form inputs.

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

When you retrieve the them from url you'll wnt to decode then with [url=http://php.net/urldecode]urldecode[/url]
Eg:
[code=php:0]$name = urldecode($HTTP_GET_VARS['Name']);
$class =  urldecode($HTTP_GET_VARS['Class'];)
$level =  urldecode($HTTP_GET_VARS['Level']);[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.