Rating System user validation
Posted: Sun Apr 27, 2003 10:28 am
I've picked up an image gallery script from SourceForge that is almost perfect for what I want with one exception. The rating system sporadically allows multiple votes from the same user and I'm not sure why. This is the code used to determine if an image has already been rated;
This is the code associated with retrieving the rating;
Now in the MySQL the table for ratings has the IP number along with the image file name. What I can't figure out is why when it checks to see if the image has already been rated it does not return the IP in that table and deny another vote.
This may not be enough information and if not I would be happy to offer more, along with the URL where this is set up. Any suggestions on where to start looking to resolve this issue would be greatly appreciated.
Cheers!
Code: Select all
<?php
function already_rated($nom)
{
global $sDB,$nConnection,$sTableRatings;
$cmd="select * from $sTableRatings where pic_name='".addslashes($nom)."' and ip='".getenv("REMOTE_ADDR")."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return($row);
}
?>Code: Select all
<?phpfunction get_rating($nom)
{
global $sDB,$nConnection,$sTableRatings;
$cmd="select avg(rating), count(*) from $sTableRatings where pic_name='".addslashes($nom)."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return ($row[1]?$row[0]:false);
}
?>This may not be enough information and if not I would be happy to offer more, along with the URL where this is set up. Any suggestions on where to start looking to resolve this issue would be greatly appreciated.
Cheers!