Solved

please help in simple php file

Posted on 2011-03-08
4
300 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 500 total points
Comment Utility
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 500 total points
Comment Utility
0
 

Author Comment

by:helyonprime96
Comment Utility
thanks. i will test it
0
 

Author Closing Comment

by:helyonprime96
Comment Utility
thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now