Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Writing a Top Ten App
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Writing a Top Ten App

 Post Reply Post Reply Page  12>
Author
choshour View Drop Down
Newbie
Newbie
Avatar

Joined: 24 February 2003
Location: United States
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote choshour Quote  Post ReplyReply Direct Link To This Post Topic: Writing a Top Ten App
    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
%>

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2003 at 10:03am

The SQL string is Select TOP 10 * FROM Ratings;

Mart.

Back to Top
choshour View Drop Down
Newbie
Newbie
Avatar

Joined: 24 February 2003
Location: United States
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote choshour Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2003 at 10:48am
make ten fields in the db?
Back to Top
choshour View Drop Down
Newbie
Newbie
Avatar

Joined: 24 February 2003
Location: United States
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote choshour Quote  Post ReplyReply Direct Link To This Post 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



Edited by choshour
Back to Top
dreaming View Drop Down
Newbie
Newbie
Avatar

Joined: 21 June 2003
Location: United Kingdom
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote dreaming Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
choshour View Drop Down
Newbie
Newbie
Avatar

Joined: 24 February 2003
Location: United States
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote choshour Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.