bholzer Posted February 17, 2010 Share Posted February 17, 2010 This is not working and i can not figure out why, i want to only allow users to vote once per hour. ANY IDEAS?!? <?php $con = mysql_connect("localhost","login","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); if( $_COOKIE["Hasvoted"] == "1") { echo "No more voting for you"; } else {$sql="UPDATE vote SET votes = votes +1 WHERE pic_id = $_POST[pic]"; setcookie("Hasvoted", "1", time()+3600); if (!mysql_query($sql,$con)) { die('Something went wrong: ' . mysql_error()); } } header("Location: http://www.site.com"); mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/192326-cookie-vote-help/ Share on other sites More sharing options...
premiso Posted February 17, 2010 Share Posted February 17, 2010 You can try to properly define setcookie by adding the optional params, such as host and path and see if that sets the cookie for you. Link to comment https://forums.phpfreaks.com/topic/192326-cookie-vote-help/#findComment-1013485 Share on other sites More sharing options...
bholzer Posted February 17, 2010 Author Share Posted February 17, 2010 well, im pretty new to php, so i dont even really know how to set it correctly! Link to comment https://forums.phpfreaks.com/topic/192326-cookie-vote-help/#findComment-1013487 Share on other sites More sharing options...
idontkno Posted February 17, 2010 Share Posted February 17, 2010 well, im pretty new to php, so i dont even really know how to set it correctly! bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] ) That probably was the problem, as PHP.net states that all values are required EXCEPT for the name. Link to comment https://forums.phpfreaks.com/topic/192326-cookie-vote-help/#findComment-1013488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.