0

In My application after successful login in index page, I want to redirect the page(whatever in goto variable)

Take an example I want to get page1.php?name=ss&age=75 as goto variable.

www.example.com/index.php?goto=page1.php?name=ss&age=75

But I got only page1.php?name=ss from $_REQUEST['goto']

Please provide me the best way to get whole url

Sridhar
  • 2,228
  • 10
  • 48
  • 79

3 Answers3

2

You need to urlencode your variable, doing urlencode('page1.php?name=ss&age=75') will give you page1.php%3Fname%3Dss%26age%3D75 which you can plug to the query string without it being misinterpret.

reko_t
  • 55,302
  • 10
  • 87
  • 77
0

www.example.com/index.php?goto=page1.php?name=ss&age=75 is not a valid URL. It contains two ? for instance.

You will have to pass the goto parameter around some other way. You could base64 encode it before you put it into a URL, and then base64 decode it once you need it to redirect the user.

Or you could simply url encode/decode it.

Jan Hančič
  • 53,269
  • 16
  • 95
  • 99
  • 1
    You don't even need to urldecode it, that happens automatically.. All you need to do is urlencode it when you plug it to your query string, and it'll have the correct value on PHP's side. – reko_t Jan 30 '13 at 08:58
0

replace all & by @ symbol in url goto variable like page1.php@name=ss@age=45

and replace all @ symbol by & in the received goto variable