1

I have a page that does a re-direct as such, following the guidelines from this SO Post.

header("Location: http://www.fivefoo.com?uid=johnny");
die();

This small php file is located here in index.php of course.

http://www.fivefoo.com/johnny

What I did was just add on a query to the re-direct

?uid=johnny.

First and main question. Am I allowed to to do this?

Secondly, where do I retrieve the query values. My guess, would be the $_GET global.

Community
  • 1
  • 1

2 Answers2

1

Yes you are allowed to do this (why shouldn't you be?)

Yes, you can get the query values from the $_GET superglobal array. More specifically, $_GET['uid'] will contain the text 'johnny' (without the quotes of course).

Simon Forsberg
  • 13,086
  • 10
  • 64
  • 108
  • I'm not use to seeing the query directly after the domain, that was on thing, I was wondering about. – api implementor - johnny Jul 29 '13 at 23:06
  • @johnnysirocco `http://www.fivefoo.com?uid=johnny` will be the same as `http://www.fivefoo.com/index.php?uid=johnny` (index.php could also be index.html, or any other handler file either put there or defined in .htaccess). That's perfectly fine. – Simon Forsberg Jul 29 '13 at 23:09
  • @johnnysirocco Some time gotta be the first :) Please mark answer as accepted if it helped. – Simon Forsberg Jul 29 '13 at 23:11
0
  1. Yes, you can do this.
  2. Yes, the $_GET is used for this, so $_GET['uid'] in your example would return 'johnny'.

More info here