Hi,
I have some code similar to that below. What I want to do is add a simple voting system that does not allow multiple votes for the same image, but the user is still able to vote for other images.
So far i've got it to only allow one vote by setting the cookie containing the link to the image. Yet when i try to vote for another image it won't let me vote even though the links are different.
Can anyone help me figure this one, i've been on it for a few hours now and i'm running out of hair to remove, please, I really don't wanna start on the pubes!
if (isset($_COOKIE['vote']))
{
foreach ($_COOKIE['vote'] as $name => $value)
{
if($name==$link)
{
echo "already exists;"
}
else
{
$sql = mysql_query("SELECT * FROM links WHERE link='$link'");
$get = mysql_fetch_array($sql);
$oldpoints = $get['points'];
$newpoints = $oldpoints + $points;
mysql_query("UPDATE links SET points='$newpoints' WHERE link='$link'");
$value = "Has been voted for.";
setcookie("vote[$link]", $value, time()+3600, "/");
}
}
}
lets assume that the cookie is set already after the first vote and that $link is the link for each image.
Thanks
Ant
P.S. I say voting system, but as you might have guessed it updates points in a database.