Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Logging ip addresses

Options
  • 22-03-2004 1:12pm
    #1
    Registered Users Posts: 986 ✭✭✭


    i have a small website, but i want to track ip address as people use the message board on the site, eg when they click the submit button or when they enter the message board page, how can i do this?


Comments

  • Closed Accounts Posts: 1,163 ✭✭✭Emboss


    if you're using PHP look into REMOTE_ADDR


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Isn't that info stored in the Web servers logs? I remember from my Apache days seeing ip addresses which accessed the site in the log files. Try looking in there.


  • Registered Users Posts: 986 ✭✭✭wild_eyed


    i am getting thefollowing error on the second line of this code
    Parse error: parse error in /home/www/web277/web/postform.php on line 45

    i.e. line 45 of the entire page = line 2 of this code.

    can anyone tell me whats wrong.

    noob.


    [PHP]<?
    $ip = $_SERVER;
    $logged_string = $ip . "|" . . date("j M Y g:i a");
    $file = fopen("userIP.log", "a");
    fputs($file, $logged_string, strlen($logged_string));
    fclose($file);
    ?> [/PHP]


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    [PHP]<?
    $ip = $_SERVER;
    $logged_string = $ip . "|" . /* extra dot here -> */ . date("j M Y g:i a");
    $file = fopen("userIP.log", "a");
    fputs($file, $logged_string, strlen($logged_string));
    fclose($file);
    ?> [/PHP]


  • Registered Users Posts: 986 ✭✭✭wild_eyed


    sorry, do u mean that i shud place an extra dot were the comments are?

    like this?

    [PHP]
    <?
    $ip = $_SERVER;
    $logged_string = $ip . "|" . . . date("j M Y g:i a");
    $file = fopen("userIP.log", "a");
    fputs($file, $logged_string, strlen($logged_string));
    fclose($file);
    ?>
    [/PHP]


  • Advertisement
  • Closed Accounts Posts: 304 ✭✭Zaltais


    Originally posted by wild_eyed
    sorry, do u mean that i shud place an extra dot were the comments are?

    like this?


    No he means you have an extra dot. It should be ->

    [PHP]
    <?
    $ip = $_SERVER;
    $logged_string = $ip . "|" . date("j M Y g:i a");
    $file = fopen("userIP.log", "a");
    fputs($file, $logged_string, strlen($logged_string));
    fclose($file);
    ?>
    [/PHP]


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    As above. Sorry, I should have just posted the correct code instead of putting that comment in there :p.


  • Registered Users Posts: 986 ✭✭✭wild_eyed


    thanks is working grand, one thinbg though, it's placing all the log entries on the same line, how can i make it start a new line for each entry?


  • Registered Users Posts: 2,157 ✭✭✭Serbian


    Try the following:
    [PHP]
    <?
    $ip = $_SERVER;
    $logged_string = $ip . "|" . date("j M Y g:i a") . "\r\n";
    $file = fopen("userIP.log", "a");
    fputs($file, $logged_string, strlen($logged_string));
    fclose($file);
    ?>
    [/PHP]


Advertisement