Jump to content

Problem with poll - don't adds' votes


Spikerok

Recommended Posts

input, output works ok, but i have error with processing votes, when user have voted he will move to action.php where are script will check his ip, and will insert his vote in needed field. I believe checking function to check ip is working ok, but there is problem with inserting user's vote into database or can their be some thing else?

 

my action.php script, where are all the main things are happening. And here im getting that error.

<?php
require_once '../library/config.php'; 

session_register("operation");

Header("Location: results.php");

$quer = mysql_query("SELECT * FROM current_poll WHERE Status='on' OR Status='paused'");
$status = mysql_fetch_array($quer);
$poll_type=$status['type'];
$answers=explode("|", $status['Answers']);
$n=count($answers);
if ($status['Status']=="paused") {
     $operation="paused";
     exit;
     }

$myquery = mysql_query("SELECT ip FROM current_poll_results WHERE ip='$REMOTE_ADDR' AND poll_id='$vote_id'");
$yes = mysql_fetch_array($myquery);
if ($yes['ip']) {
     $operation="already_voted";
     exit;
     }


if ($_COOKIE["id"]==$vote_id) {
     $operation="already_voted";
     exit;
     }
else{
        if ($poll_type!="check") {
            mysql_query("INSERT INTO current_poll_results VALUES ('$answer', '$REMOTE_ADDR')");
            }
        elseif ($poll_type=="check") {

            for ($i=0; $i<$n; $i++){
                    $u = "ans_".$i;
                    if (isset ($$u)) {
                    if ($$u=="true") { mysql_query("INSERT INTO current_poll_results VALUES ('$i', '$REMOTE_ADDR')");}
                    }
                    }
            }
$operation="ok";
setcookie ("id", $vote_id, time()+31536000);
}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/153619-problem-with-poll-dont-adds-votes/
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.