tags:

views:

55

answers:

2

How can I post a full URL in PHP?

For example:

I have a form allowing individuals to submit a long url. The resultant page is /index.php?url=http://www.example.com/

This is fine for short URLs, but for very long and complex URLs (like those from Google Maps) I need to know how to keep all of the data associated with variable url.

+1  A: 

You need to percent encode the string — otherwise characters which have special meaning in URIs will have that special meaning instead of being treated as data.

http://php.net/urlencode

If users submit this data via a form, then it will be automatically encoded.

If you plan to include the URI in a link in an HTML document, then don't forget to convert special characters to HTML entities.

David Dorward
perfect, thanks
ServAce85
A: 

You sort of answer your own question:

How can I post a full URL in PHP?

If very long URLs are getting truncated by the users' browsers, your only option is to re-work your system to POST the URL to your script, as opposed to passing it in the query string.

If there is some condition that frustrates the use of a POST request, you should update your question with more detail about what your system does.

timdev
thanks for the response
ServAce85