Forums

ASP

This topic is locked

Stop users adding more than one review to database

Posted 26 Sep 2005 15:47:31
1
has voted
26 Sep 2005 15:47:31 billy jones posted:
I need a piece of code or extension which alerts the user that they have already entered a review for a particular product on the database.

When a review is added to a product the field "review_text", "score" and a hidden field called "user_name" are sent to the table on the database.

Ideally I want it so a user cannot add more than one review to a particular resource.

Replies

Replied 27 Sep 2005 11:47:06
27 Sep 2005 11:47:06 Michael Behan replied:
I'm assuming a user has logged in before they go to the insert review page and that you are using the default dreamweaver login behaviour. I'm also assuming the review table has a productId or similar field.

create a new recordset with the following SQL

select * from reviewTable WHERE user_name = param1 AND productId = param2

param1 is defined as Session("MM_Username"
param2 is defined as Request("productId" (or however you pass in the product id to the review page)

Now select your entire insert record form and put it in a "show if recordset is empty" region for the above recordset. Then somewhere type a message like "you have allready reviewed this item" and put that in a "show if recordset is not empty" region.
Replied 28 Sep 2005 15:26:02
28 Sep 2005 15:26:02 billy jones replied:
Ive got the standard login behaviour - (field called "user_name" and the product identifier is "productid"

I have set up a recordset called "rs_already_reviewed" and put the user_name as param1 and productid as param2.

Ive inserted the show region if recordset is empty and not empty - set to rs_already_reviewed.

Nothing different is happening however, I can still add a second, third review etc for the same user and product. Am I maybe missing something out?

Edited by - moss2076 on 28 Sep 2005 15:40:31
Replied 29 Sep 2005 12:57:06
29 Sep 2005 12:57:06 Michael Behan replied:
that should work ...

can you put your code up so I can have a look.
Replied 29 Sep 2005 14:33:06
29 Sep 2005 14:33:06 billy jones replied:
Ive emailed you the files with the review page..

Reply to this topic