I’m using a free account on infinityfree, to create my website. When I was working with HTML, it was absolutly perfect. But when I started working with PHP, I ran into a few errors. So: is this code
echo $_SERVER[‘HTTP_REFERER’];
not working on a free account?
I saw this code working on w3schools, but when I tried it, it didn’t work. (This was the only thing on the page, so it can’t be an error of something else!)
It should work without any problems. Can you please elaborate on what you mean by “it didn’t work”? Does the value not exist? Is it empty? Does it contain other content than you expected?
Well, when I use that code on my page, I get no results (empty white page). Again, this is the only code on the page, so it cannot be affected by any other code!
‘HTTP_REFERER’
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
@underlyingglitch said:
Well, when I use that code on my page, I get no results (empty white page). Again, this is the only code on the page, so it cannot be affected by any other code!
Did you try any other way to check the variable? Like var_dump($_SERVER); to see all defined variables? Also, have you made sure that your request actually has a Referrer header? If your browser did not sent a Referrer header, then obviously no such header will be present in PHP either.
Also, did you make sure the page is not crashing? Sometimes, you may see a completely blank page, but your browsers network tab shows the status code is “500”. If you enable display errors then, you might see an error page.