Solved

please help in simple php file

Posted on 2011-03-08
4
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Persistent Connections 10 33
Validating number not work with decimal 4 24
How do I update select listbox after search 2 23
CSS for Popup in ASP.NET 4 15
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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