rossmcl
Programmer
- Apr 18, 2000
- 128
Hi
I am very new to PHP, so this is probably me being stupid.
When someone visits my website, I write to a file the date, time, and IP address of visitor. Works fine, but the annoying thing is whilst I am testing the site, I get my IP address coming up on the site a lot.
I want to put in a temporary IF statement into my code until I finish doing work on it, so that if the REMOTE_ADDR of visitor is me, it doesnt write to the file.
This is the code I am using, but it doesnt seem to work. When I put it this code in, it doesnt write anything, even when people that are not the 212.... IP address visit the site. I suspect I am treating the IP address as a string or something, but I have tried double quotes and single quotes around the IP address, and neither work.
Can someone please help me. Would very much appreciate it.
RM
<?php
$filename = "VisitorLog.txt";
$handle = fopen ($filename, "a+"
;
$todaydate = date("Y-m-d H:i:s"
;
$visitorInfo = $HTTP_SERVER_VARS['REMOTE_ADDR'];
If ($visitorInfo) = "212.12.12.12"
{
}
else
{
fwrite($handle, "\r\n" . $todaydate . ' ' . $visitorInfo);
}
fclose( $handle );
// \r\n
?>
I am very new to PHP, so this is probably me being stupid.
When someone visits my website, I write to a file the date, time, and IP address of visitor. Works fine, but the annoying thing is whilst I am testing the site, I get my IP address coming up on the site a lot.
I want to put in a temporary IF statement into my code until I finish doing work on it, so that if the REMOTE_ADDR of visitor is me, it doesnt write to the file.
This is the code I am using, but it doesnt seem to work. When I put it this code in, it doesnt write anything, even when people that are not the 212.... IP address visit the site. I suspect I am treating the IP address as a string or something, but I have tried double quotes and single quotes around the IP address, and neither work.
Can someone please help me. Would very much appreciate it.
RM
<?php
$filename = "VisitorLog.txt";
$handle = fopen ($filename, "a+"
$todaydate = date("Y-m-d H:i:s"
$visitorInfo = $HTTP_SERVER_VARS['REMOTE_ADDR'];
If ($visitorInfo) = "212.12.12.12"
{
}
else
{
fwrite($handle, "\r\n" . $todaydate . ' ' . $visitorInfo);
}
fclose( $handle );
// \r\n
?>