php tutorial $ http_cookie_vars Instance voting information restrictions
if ($ http_cookie_vars ["vote"]) {
echo "<script> alert ('You have already voted, please do not repeat the vote'); history.back (); </ script>";
exit
}
$ vcount = $ _ post ["vcount"];
$ lld = $ _ post ["jump"];
$ tys = $ _ post ["tys"];
if (! $ vcount) {
echo "<script> alert ('You have not selected any voting items'); history.back (); </ script>";
exit
}
$ db = @ mysql_connect ("localhost", "root", "root") or die ("database tutorial connection failed");
mysql_select_db ("vote", $ db);
if ($ vcount && $ lld) {
if ($ tys == "1") {
$ sql = "update vote set vcount = vcount + 1 where id = $ vcount";
$ result = mysql_query ($ sql, $ db);
setcookie ("vote", "vote", time () + 3600);
echo "<script> alert ('Voting successful!'); location.href = 'vote.php? id = $ lld'; </ script>";
}
else {
for ($ i = 0; $ i <sizeof ($ vcount); $ i ++) {
$ sql1 = "update vote set vcount = vcount + 1 where id = $ vcount [$ i]";
$ result1 = mysql_query ($ sql1, $ db);
}
setcookie ("vote", "vote", time () + 3600);
echo "<script> alert ('Voting successful!'); location.href = 'vote.php? id = $ lld'; </ script>";
}
}