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