Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.