+ Reply to Thread
Results 1 to 3 of 3

Thread: PHP ip logger

  1. #1
    kloaknet is offline x10Hosting Member kloaknet is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    1

    PHP ip logger

    Hi there!

    i want to incorporate this script in my web page:

    <?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);

    ?>

    the rights i gave to the ips.txt file is 777 so that shouldn't be the problem, but it is not working. Are some php funtions blocked?

  2. #2
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: PHP ip logger

    The output is wrong, i.e. no IP address... (I had to test it myself to check -- it is helpful to say exactly WHAT isn't working when you are requesting help -- it saves a lot of time...)

    As I said I just tested it myself: the problem is you can't get an IP address using:
    Code:
    $REMOTE_ADDR
    instead use:
    Code:
    $_SERVER['REMOTE_ADDR']
    Edit://
    Here's a good link for getting user and request data, in case you need it.
    http://php.net/manual/en/reserved.variables.server.php
    Last edited by ah-blabla; 12-03-2009 at 03:27 PM.

  3. #3
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: PHP ip logger

    Register globals are off

    To get ip address you have to use $_SERVER['REMOTE_ADDR'];

    Why don't you use mysql table to store that is good option.

    EDIT:
    ah-blabla you beat me.
    Last edited by Gouri; 12-03-2009 at 09:36 AM.
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

+ 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. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

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