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

1

3 Answers 3

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.

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

Comments

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

Comments

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.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.