Php Help "View Counts"

Discussion in 'PHP' started by ozone1, Nov 28, 2008.

  1. #1
    basically there are "view counts" ( ie, number of times a video is viewed) on my video page

    im having problem with some of my members they purposely click the video they submitted to increase the popularity of the video ( say after submission he clicked the video 100 times so that it will come top in the list ) so i want to restrict it if he watch it with same ip address 100 or 10000 times it should show only 1 view count (from him) on my video page.

    im not good in php can you please tell me step by step what to do thanks

    here is the code i have on my video page

    mysql_query("UPDATE videos SET view = view+1 WHERE id = '$id'");
    Code (markup):

    Any help really appreciated Thanks !!!
     
    ozone1, Nov 28, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    For this you need to create a new table which will keep the track of the visitors who watched the videos. The table will contain at least 2 fields i.e.

    video_id, ip_address

    Whenever a user click on the video, save its IP and the video id in this new table. And before updating the view count, make sure the IP and video do not exist more than once in the table.
     
    mwasif, Nov 28, 2008 IP
  3. djzmo

    djzmo Active Member

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    
    if(!session_is_registered('viewed_' . $id))
    {
      mysql_query("UPDATE videos SET view = view+1 WHERE id = '$id'");
      $_SESSION['viewed_' . $id] = true;
    }
    
    Code (markup):
    Well, the code above won't avoid the same thing to happen at all.
    But AT LEAST, the code can reduce it.
     
    djzmo, Nov 28, 2008 IP