Simple ASP voting system source code

Source: Internet
Author: User
Tags servervariables

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>
&LT;TD height= ">"
<table width=170 height= align= "center" cellpadding=0 cellspacing=0>
<tr>
&LT;TD width=5>&nbsp;</td>
&LT;TD width=28>
<div align= "center" ></div>
</td>
&LT;TD class=hg12 valign=bottom width= "123" >&nbsp;<font color= "#000000" ><b> poll results </b></ Font></td>
&LT;TD width=12>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
<table width= "90%" border= "0" cellspacing= "0" cellpadding= "0" align= "center" >
<tr>
&LT;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>
&LT;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>
&LT;TD valign= "Top" > Serial number </td>
&LT;TD valign= "Top" > Hundred score </td>
&LT;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>
&LT;TD valign= "Top" ><%=i%>.<%=rs ("select" &i)%>:</td>
&LT;TD valign= "Top" > height=8>
<%=round (answer,3)%>%</td>
&LT;TD valign= "Top" ><%=rs ("Answer" &i)%> person </td>
<%
End If
Next
%>
<tr>
&LT;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>
&LT;TD height= ">"
<div align= "center" ></div>
</td>
</tr>
</table>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.