Print Page | Close Window

Writing a Top Ten App

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3763
Printed Date: 28 March 2026 at 7:09pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Writing a Top Ten App
Posted By: choshour
Subject: Writing a Top Ten App
Date Posted: 23 June 2003 at 10:00am

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
%>




Replies:
Posted By: Mart
Date Posted: 23 June 2003 at 10:03am

The SQL string is Select TOP 10 * FROM Ratings;

Mart.



Posted By: choshour
Date Posted: 23 June 2003 at 10:41am
That is to list the top ten teams but how can you keep someone from voting every team as number 1?  There are 48 teams in the database. I want to make it so they can only choose 1 team as number 1. One team as number 2 etc.  This would mean that they could only vote for 10 teams.


Posted By: faubo
Date Posted: 23 June 2003 at 10:48am
make ten fields in the db?

-------------
http://www.conhecerparaconservar.org - I don't know how to make you click here


Posted By: choshour
Date Posted: 23 June 2003 at 11:00am

In the database I have Ip address recorded for who has voted the rating and the team that they rated.

Is there not a way to check the IP and see if he has given another team the rating he is trying to sumbit.  I think it has to do with an If then statement but not sure how to write it.

For example if he has already rated a team number 1 then it will return you have already given out this rating.

Here is the link to what the frontend looks like
http://www.p-15.com/Team_Ratings/showteams.asp - http://www.p-15.com/Team_Ratings/showteams.asp



Posted By: dreaming
Date Posted: 23 June 2003 at 11:30am
as an extra caution to prevent someone from voting for a team again or for a certain rank again, you could also use cookies as well as the IP address. it wouldn't guarantee that voting again and again wouldn't happen, but it would decrease the chance.

-------------
- Awake & Dreaming -
we make your dreams


Posted By: choshour
Date Posted: 23 June 2003 at 11:37am

I failed to mention it but I am Also using cookies.  The code at the beginning shows it and is setup to keep people from voting more than once for a team.  I just want to limit a little further so you can not give the same ranking twice. 

I do appreciate the advice



Posted By: Gullanian
Date Posted: 23 June 2003 at 2:48pm
Another thing to drasticaly reduce chance of voting more than once is to require users to sign up, and then you can store user ID, and if you made accounts email activated 99.9% wont be bothered to keep signing up.


Posted By: choshour
Date Posted: 23 June 2003 at 3:58pm

I am using a mod that was made that check permission so I can use the forum database userlist.  Is their a way that when they vote the username from another database can be recorded with the vote?

I have two tables
Teams: TeamID, TeamName, HeadCoach, League
Ratings: RatingID, Rating, Ip, Username, TeamID



Posted By: Gullanian
Date Posted: 23 June 2003 at 4:05pm
Yes, just open the database in the code store the values in variables, shut it down and open database 2.  Its better to merge them however,


Posted By: choshour
Date Posted: 23 June 2003 at 6:08pm

Back to my first question is their a way to do this and if so what would the sql statement be to get ratings and teamid based on ip?

Then what would be the if else state to check?




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net