0

Im slightly stuck with the get variables for a php script. I want to be able to accept a single url via

$_GET["url"]

however i have found that if users pass a url like this in

https://www.google.co.uk/search?q=PHP&oq=PHP&aqs=chrome..69i57j69i60j69i61j69i60l2j69i59.3094j0j4&sourceid=chrome&es_sm=0&ie=UTF-8

the script will only read this

https://www.google.co.uk/search?q=PHP

My question is whether there is a way to read the whole url including the other get keys?

1
  • I don't understand....All you do is $_GET and you can retrieve that entire string. Commented Sep 8, 2014 at 16:40

1 Answer 1

1

The problem is that you're not encoding things correctly for use in the URL. Reserved characters like & and ? must be encoded, or they become ambiguous.

Use urlencode(). That URL becomes:

https%3A%2F%2Fwww.google.co.uk%2Fsearch%3Fq%3DPHP%26oq%3DPHP%26aqs%3Dchrome..69i57j69i60j69i61j69i60l2j69i59.3094j0j4%26sourceid%3Dchrome%26es_sm%3D0%26ie%3DUTF-8

... which is then safe to use as a value in your query string.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.