I have created a database which, amongst other things, holds data for votes cast for a place. I have managed to get it working to the point where the votes get counted and display correctly.
I want to introduce a cookie to make it harder for people to keep pressing vote. This is the code I have got thus far (sorry if it is horribly wrong am new to this). Basically I want it to check if the form has been sent and if a cookie does not exist, if so add a vote (otherwise do nothing - I'm still looking in to code to disable the form button in my software)
The page displays correctly but I get the "cannot display header information" message when clicking on the button and when I refresh, the vote has still been counted.
if (isset($_POST['votes']) && !isset($_COOKIE["placex"])) {
$query = mysql_query("UPDATE Places SET Votes = Votes +1 WHERE Places.Place='PlaceX'");
setcookie("placex");
}
// Default query
$sql = "SELECT * FROM Places WHERE Place='PlaceX'";
//execute the SQL query and return records
$result = mysql_query($sql);
?>
Thanks for any ideas!