$get Doesn't Seem To Work If Not In The Same Page
Solution 1:
$_GET
is a variable that is repopulated every time a new HTTP request is made to the server. A "request" is any HTTP interaction done with your application. If you download the html content for the page, and 3 more requests for your php app are issued in that page (images, ajax calls, iframes, etc), that's 4 requests in your php code. If you make 2 AJAX calls to your server, that is still 2 separate requests, even if they were issued from the same loaded document on the same client.
The value of $_GET
does not carry across requests -- it is reset each time. For instance, if you access page2.html?foo=bar
, and then click on a link <a href="page1.html?baz=quux">page1</a>
, the $_GET
during the second request will match parameters from the target link, and none of the first.
If your overall goal is to carry state between the requests, you will have to either propagate the parameters from the query string (e.g. reward1
) when you generate the link templates to the second page, or keep track of parameters on the server, e.g. inside session variables.
If the first page is only ever directly visited from the second, you might be able to extract the parameter from the previous page by consulting the Referer
[sic] HTTP header, but I would recommend that only as a last resort, or as a learning exercise. Referer headers are not always reliable, especially when going from https to http, or when redirects are involved.
Post a Comment for "$get Doesn't Seem To Work If Not In The Same Page"