I don't understand, why would i want to change my $msg1 and $msg2 vars to $msg?... that would do nothing but cause problems, hehe 🙂
Those two vars are passed on from previous pages. Thanks for making me realise though, yes there is an optimisation problem -- it would be better if:
if(mysql_num_rows($validate_voter)>0)
{
$msg1 = 1; //msg1: 1=Cheater, 2=Not cheater
$msg2 = 2; //msg2: 1=Display, 2=Don't Display
header("Location: http:" . $filename . "?" . $php_query . "&pollreq=" . $poll_results_page . "&msg1=" . $msg1 . "&msg2=" . $msg2 . "#poll");
}
Which makes the new code:
// Checks if this ip has voted before
$validate_voter = mysql_query("select votersIP from $poll_log where votersIP = '$REMOTE_ADDR' and pollID=$pollID") or DIE(mysql_error());
if(mysql_num_rows($validate_voter)>0)
{
$msg1 = 1; //msg1: 1=Cheater, 2=Not cheater
$msg2 = 2; //msg2: 1=Display, 2=Don't Display
header("Location: http:" . $filename . "?" . $php_query . "&pollreq=" . $poll_results_page . "&msg1=" . $msg1 . "&msg2=" . $msg2 . "#poll");
}
else
{
$msg1 = 2;
$msg2 = 2;
// Updates vote count number (adds 1)
mysql_query("update $poll_data set optionCount=optionCount +1 where pollID=$pollID and voteID=$voteID") or die (mysql_error());
// Updates vote count number TOTAL (adds 1)
mysql_query("update $poll_data set optionTotal=optionTotal +1 where pollID=$pollID") or die (mysql_error());
// Updates IP info for anti-cheat
mysql_query("insert $poll_log set votersIP='$REMOTE_ADDR', timestamp=now(), pollID=$pollID, voteID=$voteID") or die (mysql_error());
setcookie("poll[0]","voted",0,"/","www.u-clan.net");
header("Location: http:" . $filename . "?" . $php_query . "&pollreq=" . $poll_results_page . "&msg1=" . $msg1 . "&msg2=" . $msg2 . "#poll");
}
Although i still cant figure out why the setcookie() function isn't working... am i checking in the wrong place or something?