首页 > 开发 > PHP > 正文

php $HTTP_COOKIE_VARS 实例投票资料限制

2024-05-04 21:58:27
字体:大 中 小
来源:转载
供稿:网友
  1. if ($http_cookie_vars["vote"]) { 
  2.  echo "<script>alert('您已经投过票了,请不要重复投票');history.back();</script>"; 
  3.  exit; 
  4. } 
  5. $vcount=$_post["vcount"]; 
  6. $lld=$_post["jump"]; 
  7. $tys=$_post["tys"]; 
  8. if (!$vcount) { 
  9.  echo "<script>alert('您还没有选择任何投票项目');history.back();</script>"; 
  10.  exit; 
  11. } 
  12. $db=@mysql_connect("localhost","root","root") or die("数据库教程连接失败"); 
  13. mysql_select_db("vote",$db); 
  14. if ($vcount&&$lld) { 
  15.  if ($tys=="1") { 
  16.   $sql="update vote set vcount=vcount+1 where id=$vcount"; 
  17.   $result=mysql_query($sql,$db); 
  18.   setcookie("vote","vote",time()+3600); 
  19.   echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>"; 
  20.  } 
  21.  else { 
  22.   for ($i=0;$i<sizeof($vcount);$i++) { 
  23.    $sql1="update vote set vcount=vcount+1 where id=$vcount[$i]"; 
  24.    $result1=mysql_query($sql1,$db); 
  25.   } 
  26.   setcookie("vote","vote",time()+3600); 
  27.   echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";//开源代码Vevb.com 
  28.  } 
  29. } 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表