Forums
This topic is locked
Picture Rating Cookies Problem
Posted 09 Dec 2001 17:22:16
1
has voted
09 Dec 2001 17:22:16 Matthew Dehait posted:
Here's the problem:I've made a rating system for pictures on my site, which is working well, but with one problem. It uses a cookie to tell if you've voted, and if you have cookies turned off you can just crank in the votes. Apparently some IDIOT is infatuated with green cars on my site, and is screwing up the whole thing.
The URL of the page is: www.hardcoremopar.com/gallery/pixsearch.asp
Don't worry it's a car site, not a porn site!
Here's the code of the part that does the vote adding and cookie setting. I want it to not add the vote if they won't accept the cookie to show that they've voted.
Thanks for your help and time,
Matt Dehait
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/Pix.asp" -->
<%
if(Request.QueryString("pixRated" <> "" then cmdRating__varRATE = Request.QueryString("pixRated"
if(Request.QueryString("pixID" <> "" then cmdRating__varID = Request.QueryString("pixID"
%>
<%
'This following part is to add rate values to RATE_VALUE field in the database. If the current value in the database is 247, and the user chooses to vote 5 star, the new value will be 252. This rate value will be added every time a vote is made. Also, at the same time, the number of users that voted is increased 1. If you divide the number of rate value (252)by the numberof users who voted, you will get the average vote. This average vote is either 2, 3, 4, 5,6 decimal. We will take care of that on the default and detail pages.
%>
<%
set cmdRating = Server.CreateObject("ADODB.Command"
cmdRating.ActiveConnection = MM_Pix_STRING
cmdRating.CommandText = "UPDATE TASKS SET pixRated = pixRated + " + Replace(cmdRating__varRATE, "'", "''" + ", pixRates = pixRates + 1 WHERE pixID = " + Replace(cmdRating__varID, "'", "''" + ""
cmdRating.CommandType = 1
cmdRating.CommandTimeout = 0
cmdRating.Prepared = true
cmdRating.Execute()
%>
<%
'This following part is to create some cookies to store voting info. It stores the id of the article (cmdRating__varID is the parameter variable if you look above) as cookie name and the rate value as the value. Thus, when a user has voted, this cookie is in his hard drive. When he looks at this same article again, he won't see the voting form and won't be able to re-vote on this article.
%>
<%
Response.Cookies(cmdRating__varID) = cmdRating__varRATE
Response.Cookies(cmdRating__varID).Expires = Date + 1000
%>
<%
'After the command above is done which updated the values in the database and set a cookie for the article, this will redirect users back to the page they were on
%>
<%
Response.Redirect "pixdetailrate.asp?pixID=" & cmdRating__varID
%>
<html>
<head>
<title>Picture Rating</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>
<font face='Verdana'></font id='Verdana'>