0

I have a URL like:

http://www.example.com/page.php#tabname

The hash will automatically open a specific tab on the page.

I need to work with a _GET variable, and the URL is like:

http://www.example.com/page.php#tabname?color=red

Then on the page, I have:

echo $_GET['red'];

...but I am getting an undefined index error. How do I get PHP to recognize the variable?

2
  • The # part of a url typically stays on the client - the browser doesn't send any of it to the server. You could have some javascript that queries it and sends it... Commented Jun 10, 2015 at 16:17
  • It should also be echo $_GET['color'] Commented Jun 10, 2015 at 17:12

2 Answers 2

2

Anything after the hash is not sent to the server. Regardless, you should probably format your url so you send the GET parameters correctly.

http://www.example.com/page.php#tabname?color=red

should be

http://www.example.com/page.php?color=red#tabname

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

Comments

1

You need to put the query string before the hash:

http://www.example.com/page.php?color=red#tabname

Comments

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.