Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2006
    Location
    India
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how to count hits and unique IP?

    hi all,
    I want to track and save total hits that are done on my site.
    I also want to save te unique IPs from which my site is being seen.
    how can I do this using PHP.

    I think there will be need to make a MYSQL database to save the hits and IPs,
    how can I proceed in this?

    Please solve my problem.

    regards,
    Amit Chouhan,
    amitchouhanji@gmail.com

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    simple program / database
    Mysql:
    Code:
    CREATE TABLE ip (ip VARCHAR(255) NOT NULL);
    PHP Code:
    $ip $_SERVER['REMOTE_ADDR'];
    // connect to db
    $query mysql_query("SELECT * FROM ip WHERE ip='$ip';");
    $result mysql_fetch_array($query);
    if (isset(
    $result[ip]) || $result[ip] != $ip){
    mysql_query("INSERT INTO ip (ip) VALUES ('$ip');");


  • #3
    New Coder
    Join Date
    Jul 2006
    Location
    India
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx Mwnciau,
    I think its working.

    thanx for ur time ,

    regards,
    Amit Chouhan,
    amitchouhanji@gmail.com


  •  

    Posting Permissions

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