I am stuck big time on this problem and google has been of no help to me so far. I am trying to find a way to preserve white space in a URL with moderate to no luck.
I have a form that needs to gather post data, mail it, and then append the post data to the URL as comma separated value and redirects them to a page where they download a product.
Once the user presses download that page reads the data in the URL and applies it to a billing invoice (the program is billed on time usage).
A simplified example:
$addressOne = $_POST['addressOne']; $newURL = "http://subdomain.domain.com/connectnow=on?" . ", Address1=" . $addressOne; If(mailSent) { header("Location: $newURL") } There are a lot more values obviously, but the address is one of the areas that I am having this issue.
I have tried doing something like:
$newURL = str_replace(" ", " ", $newURL); That worked as far as preserving the whitespace in the URL visually, but when the program that gets downloaded reads the URL it replaces the as %C2%.
I have also tried:
$newURL = str_replace(" ", " \40", $newURL); That made the spaces in the URL convert back to %20.
Any guidance would be appreciated.
urlencode()andurldecode()?urlencodeanddecodeGET␣/virt/path?params␣HTTP/1.1. Extra spaces there would invalidate it. Which is why browsers substitute+or%20right away. -- Also please don't copy sample code from Word etc. Those typographic quotes make poor examples for any other users that accidentally come across this question.