Rumah  >  Artikel  >  php教程  >  php $HTTP_COOKIE_VARS 实例投票资料限制

php $HTTP_COOKIE_VARS 实例投票资料限制

WBOY
WBOYasal
2016-05-25 16:42:471714semak imbas

<?php
if ($http_cookie_vars["vote"]) {
    echo "<script>alert(&#39;您已经投过票了,请不要重复投票&#39;);history.back();</script>";
    exit;
}
$vcount = $_post["vcount"];
$lld = $_post["jump"];
$tys = $_post["tys"];
if (!$vcount) {
    echo "<script>alert(&#39;您还没有选择任何投票项目&#39;);history.back();</script>";
    exit;
}
$db = @mysql_connect("localhost", "root", "root") or die("数据库教程连接失败");
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(&#39;投票成功!&#39;);location.href=&#39;vote.php?id=$lld&#39;;</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(&#39;投票成功!&#39;);location.href=&#39;vote.php?id=$lld&#39;;</script>";
        
    }
}
?>


教程链接:

随意转载~但请保留教程地址★

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn