Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.