当前位置:编程学习 > asp >>

简单asp投票系统源码

本文章 一款简单asp教程投票系统源码,同时可以判断用户是否是当天第一次投票,如果不是就提示感谢您的支持,您已经投过票了,谢谢,否则就增加投票资料,并且把用户的ip地址保存到cookies里面,这样可以判断用户是否投票了。

<%dim options,total,sql,i,answer
if request.querystring("stype")="" then
 if request.servervariables("remote_addr")=request.cookies("ipaddress") then
  response.write"<script language=网页特效>alert('感谢您的支持,您已经投过票了,谢谢!');"
  response.write"javascript:window.close();</script>"
 else
  options=request.form("options")
  response.cookies("ipaddress")=request.servervariables("remote_addr")
  conn.execute("update vote set answer"&options&"=answer"&options&"+1 where ischecked=1")
 end if
end if
%><head><title>投票结果</title>
<link href=images/css教程.css rel=stylesheet>
</head>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td height="29">
        <table width=170 height="20" align="center" cellpadding=0 cellspacing=0>
          <tr>
            <td width=5> </td>
            <td width=28>
              <div align="center"></div>
            </td>
            <td class=hg12 valign=bottom width="123"> <font color="#000000"><b>投票结果</b></font></td>
            <td width=12> </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="29">
      <table border="0" cellpadding="0" cellspacing="0" width="95%" height="48" style="border-collaps教程e: collapse" align="center">
        <%
total=0
set rs=server.createobject("adodb.recordset")
sql="select * from vote where ischecked=1"
rs.open sql,conn,3,3
%>
        <tr>
          <td height="48" valign="top" colspan="3" align=left><font color="#000000"><br>
            ==================www.zzzyk.com=======================<br>
          </font> <font color="#000073"> <%=rs("title")%></font> </td>
        </tr>
        <tr>
          <td valign="top">序号</td>
          <td valign="top">百比分</td>
          <td valign="top">人数</td>
        </tr>
        <%
for i=1 to 8
 if rs("select"&i)<>"" then
  total=total+rs("answer"&i)
 end if
next
%>
        <%for i=1 to 8
 if rs("select"&i)<>"" then
  if total=0 then
   answer=0
  else
   answer=(rs("answer"&i)/total)*100
  end if
%>
        <tr>
          <td valign="top"><%=i%>.<%=rs("select"&i)%>:</td>
          <td valign="top"><img src=images/rscount.gif width=<%=int(answer*2)%> height=8>
            <%=round(answer,3)%>%</td>
          <td valign="top"><%=rs("answer"&i)%>人</td>
          <%
 end if
next
%>
        <tr>
          <td colspan="3"> 共有【<%=total%>】人参加投票<br>
            =======================================================</td>
        </tr>
      </table>
      <div align="center"></div>
      <p align="center">【<a href="javascript:window.close()">关闭窗口</a>】
        <% rs.close    
set rs=nothing    
conn.close    
set conn=nothing %>
    </td>
  </tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="23">
      <div align="center"></div>
      </td>
  </tr>
</table>
补充:asp教程,高级应用
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,