首页 > 开发 > 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. $vcount=$_post["vcount"]; 
  5. $lld=$_post["jump"]; 
  6. $tys=$_post["tys"]; 
  7. if (!$vcount) { 
  8.  echo "<script>alert('您还没有选择任何投票项目');history.back();</script>"
  9.  exit
  10. $db=@mysql_connect("localhost","root","root"or die("数据库教程连接失败"); 
  11. mysql_select_db("vote",$db); 
  12. if ($vcount&&$lld) { 
  13.  if ($tys=="1") { 
  14.   $sql="update vote set vcount=vcount+1 where id=$vcount"
  15.   $result=mysql_query($sql,$db); 
  16.   setcookie("vote","vote",time()+3600); 
  17.   echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>"
  18.  } 
  19.  else { 
  20.   for ($i=0;$i<sizeof($vcount);$i++) { 
  21.    $sql1="update vote set vcount=vcount+1 where id=$vcount[$i]"
  22.    $result1=mysql_query($sql1,$db); 
  23.   } 
  24.   setcookie("vote","vote",time()+3600); 
  25.   echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";//开源代码Vevb.com 
  26.  } 

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