|
I am writing an app to make a top ten list. The people can rate each team 1 to 10. What I want to do now though is make it so they can only vote for 1 team for each rating. You can only vote one team as number 1 one team as number 2 etc until you get to ten.
This is what I have so far. It only checks to see if you have voted for the team not the rating you gave them though.
<%
dim conn dim rs dim teamId dim visitorIP dim rating dim cookie dim cookieRated
teamId = Request.Form("teamId") rating = Request.Form("rating") visitorIP = Request.ServerVariables("REMOTE_ADDR") cookie = Request.Cookies("rate_" & teamId)
set conn = Server.CreateObject("ADODB.Connection") set rs = Server.CreateObject("ADODB.Recordset") conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("????????") rs.ActiveConnection = conn if cookie = "" then cookieRated = false else cookieRated = true end if
if rating = "" then 'Invalid rating %> <font face="Verdana" size="2" color="black"> <h2 align="center">Invalid Rating</h2> <p align="center">You must select a rating first!<br><br> <a href="javascript:history.go(-1)" style="text-decoration: none">Go Back</a> </font> <% else 'Valid rating, make sure visitor hasn't already voted 'by checking the ratings table rs.Open "SELECT COUNT(*) FROM ratings WHERE ip='" & visitorIP & "' AND teamId=" & teamId if rs.Fields(0).Value = 0 then if cookieRated = false then 'Visitor hasn't rated yet, let's add it conn.Execute "INSERT INTO ratings(rating, ip, teamId) VALUES(" & rating & ", '" & visitorIP & "', " & teamId & ")" Response.Cookies("rate_" & teamId) = true Response.Cookies("rate_" & teamId).expires = Date() + 30 %> <font face="Verdana" size="2" color="black"> </p> <h2 align="center">Thank You For Rating!</h2> <p align="center">Your Team rating has been added to our database.<br><br> <a href="showteams.asp" style="text-decoration: none">Continue</a> </font> <% else 'Visitor has already rated this article %> <font face="Verdana" size="2" color="black"> </p> <h2 align="center">Already Rated</h2> <p align="center">You have already rated this teams!<br><br> <a href="javascript:history.go(-1)" style="text-decoration: none">Go Back</a> </font> <% end if else 'Visitor has already rated this article %> <font face="Verdana" size="2" color="black"> </p> <h2 align="center">Already Rated</h2> <p align="center">You have already rated this teams!<br><br> <a href="javascript:history.go(-1)" style="text-decoration: none">Go Back</a> </font> </p>
<% end if end if
I would appreciate any help. Thanks %>
|