+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP: User Logging

  1. #1
    pulse__xx's Avatar
    pulse__xx is offline x10 Sophmore pulse__xx is an unknown quantity at this point
    Join Date
    Aug 2005
    Posts
    175

    Post PHP: User Logging

    Description
    A user log can be useful in keeping track of your visitors and where they are from. The user log in this tutorial will record your users time/date of their visit, their IP, their referrer, their browser information, and the page they viewed. To see my user log in action, click here. (IP logging is blocked for privacy).

    Implementation
    First, you will need to create a log.html file and copy and paste the following code:



    QUOTE
    <table width="100%" border="1" cellspacing="1" cellpadding="1" >
    <tr bgcolor="#FFFF00">
    <th>Time/Date</th>
    <th>IP</th>
    <th>Referrer</th>
    <th>Browser</th>
    <th>Page</th>
    </tr>

    Next, copy and paste the following code to the page(s) on your site where you would like to log your users' information (most likely your main/index page):



    QUOTE
    <?php

    // Get user's time/date
    $time = date("F jS Y, h:iA");

    // Get user's IP address
    $ip = $REMOTE_ADDR;

    // Get user's referrer
    $referer = $HTTP_REFERER;

    // Get user's browser
    $browser = $HTTP_USER_AGENT;

    // Get page user came from
    $page = $_SERVER['REQUEST_URI'];

    $fp = fopen("log.html", "a");

    // Print user information to log.html file
    fputs($fp, "
    <tr>
    <td>$time</td>
    <td>$ip</td>
    <td><a href=$referer>$referer</a></td>
    <td>$browser</td>
    <td><a href=$page>$page</a></td></tr>
    ");

    fclose($fp);
    ?>

    Where it says log.html, leave it the way it is if your log.html file is in the same directory as the page(s) you've pasted this code to. Otherwise, replace it with the correct relative URL to your log.html file.

    Upload all your files and ChMOD your log.html file to 777.

    Sysque Studios for more Tutorials.

    This tutorial is brought to you by http://so-you.net/
    Last edited by pulse__xx; 11-11-2005 at 04:07 PM. Reason: Wrong link.

  2. #2
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: PHP: User Logging

    So this one you took off of this site: http://www.createblog.com/forums/ind...ode=linearplus

    Who took it off of Spoono:
    http://www.spoono.com/php/tutorials/tutorial.php?id=22


    *shakes head in disgust* How many are you going to do?

  3. #3
    XUnreal's Avatar
    XUnreal is offline x10 Sophmore XUnreal is an unknown quantity at this point
    Join Date
    Jun 2005
    Posts
    185

    Re: PHP: User Logging

    NedreN, please stop having a go at pulse_xx, hes not saying its his but he does need to put a copyright on it.


    www.MSN-Mess0rs.be
    We complete MSN's Elite!

  4. #4
    Jake's Avatar
    Jake is offline Developer Jake is an unknown quantity at this point
    Join Date
    Apr 2005
    Location
    Winona, MN
    Posts
    2,084

    Re: PHP: User Logging

    XUnreal, do you get what he is doing? no?

    well hes posting for points, simple as that, using other peoples work to gain points quickly
    Jake Omann | Developer
    █ 888-X10-9668 - jake[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004
    Premium Hosting | VPS Services

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers