Jump to content

Capturing IP Address and Browser info


yana

Recommended Posts

I am using the following two methods now to capture above mentioned info:

$ip_address = $_SERVER['REMOTE_ADDR'];

$user_browser = $_SERVER['HTTP_USER_AGENT'];

This user info is captured and sent in an email to me and works perfectly on our Test Server. However, on the Live Server this does not get captured (I get an email with a blank).

What could be the cause of this???
Link to comment
https://forums.phpfreaks.com/topic/14212-capturing-ip-address-and-browser-info/
Share on other sites

<html>
<body>
<?

$ip_address = $_SERVER['REMOTE_ADDR'];

$user_browser = $_SERVER['HTTP_USER_AGENT'];

//add From: header
$headers = "From: \"Online Survey\" webserver@localhost\r\n";

//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";

//unique boundary
$boundary = uniqid("HTMLDEMO");

//tell e-mail client this e-mail contains//alternate versions
$headers .= "Content-Type: multipart/alternative" .
  "; boundary = $boundary\r\n\r\n";

//message to people with clients who don't understand MIME
$headers .= "This is a MIME encoded message.\r\n\r\n";

//HTML version of message
$headers .= "--$boundary\r\n" .
  "Content-Type: text/html; charset=ISO-8859-1\r\n" .
  "Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("IP Address: $ip_address Browser: $user_browser"))

//send message
mail("[email protected],[email protected]", "Online Survey", "", $headers);

?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.