<?php
include("../config.php");
$id = $_GET["id"];
$rate = $_GET["rating"];
 $getusers="SELECT * from rates WHERE fid='$id'";
  $getusers2=mysql_query($getusers) or die("COuld not draw cookies");
  $getusers3=mysql_fetch_array($getusers2);
  
$vote = $getusers3["vote"];

if($vote >= "1"){
$vote = $vote+1;   
mysql_query("UPDATE rates SET rate='$rate' , vote='$vote' WHERE fid='$id'");
echo "Voted!";
}else{
mysql_query("INSERT INTO `rates` (rate, vote, fid) VALUES ('$rate' , '1' , '$id'");
echo "Voted!";
}
?>