Below is included part of a script for a polls (simple yes no) I am trying
to use cookies to determin if they have already voted or not. No errors are
displaed but, I have tried to vote, and it gives no errors, nor does it give
an increase in the database, fine you might think its doing its job right.
But no, because i asked someone else to vote on it and it still didnt go up,
and he definately has not got the cookies.
Also, is it possible to use variables within cookies' names?
as you can see I am using _$id because there is more than 1 poll likely to
be used. If anyone can help clear up this odd problem I would be very happy.
Alternatilvly, would it be easier to use a second table with IP's of those
voted and the polls wich they have and used
while($num < $max)
    if($currip == $row["voter_ip"];
        $gvarvoted = "true";
if($gvarvoted == "true")
} or something like that ?
Code follows
 include "config.php";
 include "functions.php";
$id = $HTTP_GET_VARS['id'];
$submitted = $HTTP_POST_VARS['pollsubmitted'];
$isyes = $HTTP_POST_VARS['yes'];
$isno = $HTTP_POST_VARS['no'];
/* is set, do some thin */
switch ($mode)
 $hasvoted = $HTTP_COOKIE_VARS["hasvoted_$id"];
 if($hasvoted == "hasvoted")
  /* Show Results */
 } else {
 $sql = "SELECT * FROM polls WHERE id = '$id'";
 $result = mysql_db_query($database,$sql,$db);
 $row = mysql_fetch_array($result);
 $noofresponses = $row["noofresponses"];
 $yes = $row["yes"];
 $no = $row["no"];
 $yes = $yes +1;
 $no = $no +1;
 $noofresponses = $noofresponses + 1;

  $usql = "UPDATE polls SET noofresponses = '$noofresponses', yes = '$yes'
WHERE id = '$id'";
  $res = mysql_db_query($database,$usql,$db);

  $usql = "UPDATE polls SET noofresponses = '$noofresponses', no = '$no'
WHERE id = '$id'";
  $res = mysql_db_query($database,$usql,$db);
 /* end of if(isset($hasvoted_$id) */

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to