PHP: When submitting an HTML form, is HTTP_REFERER set?

An exception was thrown in my application, but HTTP_REFERER was null, which seems strange in this case. I am wondering if you can answer a quick question:

So, I have this form:

<!-- mysite.com/index.html -->

<form action="http://mysite.com/somewhere/else">
    <input type="submit" />
</form>

When someone submits a form, I expect the parameter to $_SERVER['HTTP_REFERER']be set to a value /index.html. It's true?

+3
source share
6 answers

$_SERVER['HTTP_REFERER']is the value of the optional HTTP Referer . This header is set by the browser.

, Firefox RefControl. , , .

, /index.html, http://www.mysite.com/index.html

+1

. HTTP POST GET, Referer (Google Chrome) .

, .

EDIT:

, - , PHP:

<?php
    echo $_SERVER['HTTP_REFERER'];
?>
<form method="post"><input type="submit" value="Submit"></form>
<form method="get"><input type="submit" value="Submit"></form>
0

, URL-, , ( ), referrer. PHP.

0

, POST , , . , ( "tail -n 10 file.log" 10 ). ( PHP- site.com/php-form/) :

192.168.1.10 - - [16/Apr/2008: 16: 12: 36 +1200] "GET/php-form/HTTP/1.1" 200 2014 " http://www.referringsite.com/" Mozilla/5.0 ( Konqueror/3.5; Linux) KHTML/3.5.8 (, Gecko)"

0

Referrer , .
, - .
.

0

http://php.net/manual/en/reserved.variables.server.php

'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.
0

Source: https://habr.com/ru/post/1751276/


All Articles