Code to prevent multiple submit

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Wed Nov 07, 2012 2:22 pm

it's all about how you implement your rating system. personally, i'd have a ratings table, with the fields : id,user_id,product_id,and rating. Then you can have a stored procedure that updates or inserts based on the combination of user_id, and product_id. I'd have it so that when a user accessed a product page where they could rate, the current overall rating and their personal rating are stored in variables and displayed, and then if they make a change, or resubmit, you will know because isset($userRating) will have been populated by an existing value.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Nov 08, 2012 9:06 am

The only thing that changes is that you don't need the rating field. When they load the page, query the database to see if they've already submitted, if yes, indicate which they've voted for. Then checking if the the variable that stores their existing vote isset() lets you know if you need to insert or update if they vote again.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest