Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

please help in simple php file

Posted on 2011-03-08
4
Medium Priority
?
324 Views
Last Modified: 2013-12-25
Hello experts.
Please help me.
I need to create a php file  that if is open it logs the date,time and remote ip that opened it.
File need to save this stats into a text file.
Please help me with this.
And the last, tell me how to use it in other files.
Example  : i have a index.php file that contains many other instructions.
How to include this into index.php look alike this method : include_once.. or other...
please help.
thanks
0
Comment
Question by:helyonprime96
  • 2
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 2000 total points
ID: 35073584
The best way to proceed is to write a small file like so

UNTESTED CODE

$fp = fopen("/path/to/log/file.txt', 'a' );
fprintf( $fp, "%s %s\n", strip_tag( $_SERVER['REMOTE_ADDR'] ), date("Y-m-d H:i:s") );
fclose($fp);

and put that in a php file - say logger.php - and then include this wherever you need it

---- index.php starts
<?php
   include 'logger.php';

   ..... your code
?>
---- index.php ends

0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 2000 total points
ID: 35073595
0
 

Author Comment

by:helyonprime96
ID: 35080031
thanks. i will test it
0
 

Author Closing Comment

by:helyonprime96
ID: 35361739
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question