This article a simple ASP tutorial voting system source code, at the same time can determine whether the user is the first time to vote, if not on the hint thank you for your support, you have voted, thank you, otherwise it will increase the voting data, and the user's IP address to the cookies inside, so that you can determine whether the user voted.
<%dim Options,total,sql,i,answer
If Request.QueryString ("stype") = "" Then
If Request.ServerVariables ("REMOTE_ADDR") =request.cookies ("IPAddress") Then
Response.Write "<script language= Web page special effects >alert (' Thank you for your support, you have voted, thank you! ');"
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
%><link href=images/css Tutorial. CSS rel=stylesheet>
<table width= "90%" border= "0" cellspacing= "0" cellpadding= "0" align= "center" >
<tr>
<TD height= ">"
<table width=170 height= 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> poll results </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= ">"
<table border= "0" cellpadding= "0" cellspacing= "0" width= "the height=" style= "the" Border-collaps "" The Course 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= "valign=" "Top" colspan= "3" Align=left><font color= "#000000" ><br>
==================www.111cn.net=======================<br>
</font> <font color= "#000073" > <%=rs ("title")%></font> </td>
</tr>
<tr>
<TD valign= "Top" > Serial number </td>
<TD valign= "Top" > Hundred score </td>
<TD valign= "Top" > Number </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" > height=8>
<%=round (answer,3)%>%</td>
<TD valign= "Top" ><%=rs ("Answer" &i)%> person </td>
<%
End If
Next
%>
<tr>
<TD colspan= "3" > A total of "<%=total%>" people to participate in voting <br>
=======================================================</td>
</tr>
</table>
<div align= "center" ></div>
<p align= "center" > "<a href=" Javascript:window.close () "> Close window </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= ">"
<div align= "center" ></div>
</td>
</tr>
</table>