I have stumbled across a problem that is really really bugging me, I can't seem to figure out why it is happening.
So I have a PHP page that simply adds the visitors referring url to a database table, and then redirects them to another page. This is the code (the very first lines of code, it's where I "grab" the referring url):
<?php
include 'dbconfig.php';
if (isset($_SERVER['HTTP_REFERER'])) {
$ref = strtoupper(htmlspecialchars($_SERVER['HTTP_REFERER']));
$ref = str_replace("HTTP://", "", $ref);
$ref = str_replace("HTTPS://", "", $ref);
$ref = str_replace("WWW.", "", $ref);
$refsplit = explode('/', $ref);
$ref = $refsplit[0];
} else {
$ref = "NA";
}
It always returns an empty value (or if I remove the isset:
Undefined index: HTTP_REFERER on line 3)
Now if I post the exact same code on a diferent page (for example, the index page) it will work fine. Could it have something to do with the file where the code is written, doesn't actually render a page, it just redirects?

New Topic/Question
Reply




MultiQuote




|