Jump to content

[SOLVED] ip address logging


Gauntlet

Recommended Posts

Hello there.

 

I am trying to have my website log all ips.

 

I have set up a php script to do this.

<?php

$v_ip = $REMOTE_ADDR;
$v_date = date("l d F H:i:s");

$fp = fopen("ips.txt", "a");
fputs($fp, "IP: $v_ip - DATE: $v_date\n\n");
fclose($fp);

?>

 

My html page executes the php script in the head but no text actually gets written in the ips.txt file.

Any ideas?

 

 

*UPDATE*

I created a link in the body section of my website that launches the PHP script and it worked, it printed text to the ips.txt file but it didn't show the ip, it just showed:

 

IP:  - DATE: Sunday 27 September 06:39:37

 

So there is no ip where it is supposed to be.

 

So now I have two problems.

One is how do I have the php script automatically run when the web page is opened?

And two, why doesn't the text file display the ip?

Link to comment
https://forums.phpfreaks.com/topic/175681-solved-ip-address-logging/
Share on other sites

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.