SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get IPaddress and time?

    Hi all,
    I want to display to the users, from which IPaddress and what time the user login and last visit time...

    I know how to get IPaddress, but how to get the time at the user been login?

    and also, when a guest clicks on the link, i want to increment the count to + 1.
    If the same guest(means from same IP address) clicks more than once, i want to check the time interval between two clicks say 10 min, and then i want to increment..

    For that purpose, i want to know the IP address as well as current time.

    Can any one help me regarding this?

    Thanking you....

  2. #2
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get the time you can use php's time functions

    http://php.net/manual/en/function.time.php

    I suggest that you store the time in a cookie http://php.net/manual/en/function.setcookie.php . When a user comes to your site, check if a cookie exists, if it does, compare the time stored in the cookie to the current time.

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See:
    PHP Code:
    print_r($_SERVER); 
    This will give you the IP address and even the LAN IP too.

    And for handling the date time see the date() function.

    Edit:
    And to store the date/time, as suggested earlier, use setcookie function.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •