Spikerok Posted April 11, 2009 Share Posted April 11, 2009 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); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.