Search This Blog

Sunday, September 13, 2009

PHP, Send The Visitor's IP Adress back to You

To get the visitor's IP address, use $_SERVER[REMOTE_ADDR'], and then,
you can use the mail() function, to send the ip to your mailbox.

$ip = $_SERVER['REMOTE_ADDR'];
$to = "your_email@example.com";
$subject = "record visitor's ip";
$message = "ip is: $ip";

if (mail($to, $subject, $message)){
//do stuff if you want
}
else {
//do stuff if you like
}

No comments: