codice:
<%
'Two varibles are passed into the db
'u_input is the value if the user entered a response to
'the vote/poll question....IP is the address of the user
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")
' if the user did not enter anything in the poll on this visit
' then display the poll question and possible choices
if u_input = "" then
%>
<form method="post" action="<%= request.servervariables("script_name") %>">
Question Goes Here
<input type="radio" value="1" name="u_input">A
<input type="radio" value="2" name="u_input">B
<input type="radio" value="3" name="u_input">C
<input type="radio" value="4" name="u_input">D
<input type="radio" value="5" name="u_input">E
<input type="radio" value="6" name="u_input">F
<input type="radio" value="7" name="u_input">G
<input type="radio" value="8" name="u_input">H
<input type="radio" value="9" name="u_input">I
<input type="radio" value="10" name="u_input">L
<input type="radio" value="11" name="u_input">M
<input type="radio" value="12" name="u_input">N
<input type="radio" value="13" name="u_input">O
<input type="radio" value="14" name="u_input">P
<input type="radio" value="15" name="u_input">Q
<input type="radio" value="16" name="u_input">R
<input type="radio" value="17" name="u_input">S
<input type="radio" value="18" name="u_input">T
<input type="radio" value="19" name="u_input">U
<input type="radio" value="20" name="u_input">V
<input type="submit" value="Submit" ></p>
</form>
<%
else
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
accessdb="votes_db"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath("/mdb-database/votes_db.mdb")
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from ballot where ip ='" & u_ip & "'"
rs.Open sql, cn
if rs.eof then
' if the user has not voted previously indicate it
been_here_before="No"
end if
rs.close
if been_here_before = "No" then
' Since the user has not voted previously their input
' their vote will be added to the db
sql = "insert into ballot (ip, selection" & u_input &") "
sql = sql & "values ('" & u_ip & "',1)"
rs.Open sql, cn
end if
'This will summerize and count the records in the db
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, "
sql= sql & "sum(selection4) AS sum_selection4, sum(selection5) AS sum_selection5, "
sql= sql & "sum(selection6) AS sum_selection6, sum(selection7) AS sum_selection7, "
sql= sql & "sum(selection8) AS sum_selection8, sum(selection9) AS sum_selection9, "
sql= sql & "sum(selection10) AS sum_selection10, sum(selection11) AS sum_selection11, "
sql= sql & "sum(selection12) AS sum_selection12, sum(selection13) AS sum_selection13, "
sql= sql & "sum(selection14) AS sum_selection14, sum(selection15) AS sum_selection15, "
sql= sql & "sum(selection16) AS sum_selection16, sum(selection17) AS sum_selection17, "
sql= sql & "sum(selection18) AS sum_selection18, sum(selection19) AS sum_selection19, "
sql= sql & "sum(selection20) AS sum_selection20, count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
total5=rs ("sum_selection5")
total6=rs ("sum_selection6")
total7=rs ("sum_selection7")
total8=rs ("sum_selection8")
total9=rs ("sum_selection9")
total10=rs ("sum_selection10")
total11=rs ("sum_selection11")
total12=rs ("sum_selection12")
total13=rs ("sum_selection13")
total14=rs ("sum_selection14")
total15=rs ("sum_selection15")
total16=rs ("sum_selection16")
total17=rs ("sum_selection17")
total18=rs ("sum_selection18")
total19=rs ("sum_selection19")
total20=rs ("sum_selection20")
count=rs ("total_votes")
%>
A[img]images/red.jpg[/img]">
<%= formatnumber((total1/count)*100,1) %>%
B[img]images/yellow.jpg[/img]">
<%= formatnumber((total2/count)*100,1) %>%
C[img]images/green.jpg[/img]">
<%= formatnumber((total3/count)*100,1) %>%
D[img]images/blue.jpg[/img]">
<%= formatnumber((total4/count)*100,1) %>%
E[img]images/red.jpg[/img]">
<%= formatnumber((total5/count)*100,1) %>%
F[img]images/yellow.jpg[/img]">
<%= formatnumber((total6/count)*100,1) %>%
G[img]images/green.jpg[/img]">
<%= formatnumber((total7/count)*100,1) %>%
H[img]images/blue.jpg[/img]">
<%= formatnumber((total8/count)*100,1) %>%
I[img]images/green.jpg[/img]">
<%= formatnumber((total9/count)*100,1) %>%
L[img]images/blue.jpg[/img]">
<%= formatnumber((total10/count)*100,1) %>%
M[img]images/red.jpg[/img]">
<%= formatnumber((total11/count)*100,1) %>%
N[img]images/yellow.jpg[/img]">
<%= formatnumber((total12/count)*100,1) %>%
O[img]images/green.jpg[/img]">
<%= formatnumber((total13/count)*100,1) %>%
P[img]images/blue.jpg[/img]">
<%= formatnumber((total14/count)*100,1) %>%
Q[img]images/red.jpg[/img]">
<%= formatnumber((total15/count)*100,1) %>%
R[img]images/yellow.jpg[/img]">
<%= formatnumber((total16/count)*100,1) %>%
S[img]images/green.jpg[/img]">
<%= formatnumber((total17/count)*100,1) %>%
T[img]images/blue.jpg[/img]">
<%= formatnumber((total18/count)*100,1) %>%
U[img]images/green.jpg[/img]">
<%= formatnumber((total19/count)*100,1) %>%
V[img]images/blue.jpg[/img]">
<%= formatnumber((total20/count)*100,1) %>%
Total Votes: <%= formatnumber(count,0,0) %>
<% if been_here_before <> "No" then %>
This user has voted before and this one was <u>not</u> counted.....
<% else %>
This user has <u>not</u> voted before and this one was counted.....
<% end if %>
The I.P. Address is <%= u_ip %><% end if %>
sapreste suggerirmi una soluzione?