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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Logging ip addresses

  • 22-03-2004 12:12pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 2,170 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 2,170 ✭✭✭Serbian


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 2,170 ✭✭✭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