-1
$_SERVER['HTTP_REFERER']

What does this store? I'm doing some MySQL using PHP with the POST method of a form.

In my case I'm using this form

<form action="http://localhost/db/db.php" method="post">
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="Name" value="" maxlength="100" />
</td>
</tr>
</table>
<input type="submit">
</form>

But in my db.php it does not give me any value to $_SERVER['HTTP_REFERER']

2

4 Answers 4

4

This stores http://en.wikipedia.org/wiki/HTTP_referrer value.

Means that it stores host of previous site that user use before yours

2

ok its pretty easy, firstly the HTTP_REFERER is not a php only thing. Its a web server thing IIS has the exact same server variable.

think of it like this, when ever a client does a request to a php page, the server collects some data, the client also sends some data. These so-called server variables are a collection of the available data in the request. I would recommend checking out not just this server variable, but infact all server variables. You'll be surprised what data you can access, for example the client screen size, browser, operating system.

I'm sure someone will post the exact technical meaning of a server variable, but this overview I've given should set you straight.

2

This tells you the URL of the page that your script is being invoked from.

So, say you went to http://google.com, then navigated to your script's URL, for the lifetime of your script, the value stored in $_SERVER['HTTP_REFERER'] would be http://google.com

1
  • is it returns null or '' when it call from the same directory
    – DarRay
    Jan 29, 2011 at 0:20
0

This (usually) stores the URI which user came from to your page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.