Utilizzare PHP per visualizzare le informazioni dei visitatori
18 settembre 2010 15:10Categoria PHP
Nessun commento
Nel tutorial di oggi vedremo come recuperare alcune informazioni relative al client che visita il vostro sito.
Viasualizzeremo in particolare, l’indirizzo IP, l’host, il browser e il link di provenienza del vostro visitatore.
< ?php
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
$referred = $_SERVER['HTTP_REFERER']; // a quirky spelling mistake that stuck in php
print "<strong>Display IP address:\n";
print "$ip
\n";
print "<strong>More detailed host address:</strong>\n";
print "$hostaddress
\n";
print "<strong>Display browser info</strong>:\n";
print "$browser
\n";
print "<strong>Where you came from (if you clicked on a link to get here</strong>:\n";
if ($referred == "") {
print "Page was directly requested";
}
else {
print "$referred";
}
?>Post correlati
You can leave a response, or trackback from your own site.



