Jump to content

cookie vote help


bholzer

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.