0

This is more of an open ended question as opposed to me actually posting code but here is what I am doing:

I have several actions that give the user points toward rewards on our site. I have created several pixel trackers which use a javascript document.write to fire when the page loads, the image passes the necessary variables my PHP program with does the DB work and by using the header function, returns a GIF image. This all work great and I'm very happy with it but I need to find a solution for stopping the user from simply refreshing the page where they earned the points and keep collecting. I have tried using a PHP cookie which worked but say I navigated somewhere else on the site for example wrote 2 reviews on different products, it doesnt give me points for the 2nd review. I tried detecting refresh in javascript to stop the image from firing if so but no code seems to work right, anybody have any ideas or insight?

1 Answers1

0

You should create a table that logs the reward points and when that code processes it and adds new points it checks there first.

So each time you award a point, store it in a log: John Smith 1 point on a review id # 20029

Then when he refreshes, check the log: Did John Smith get a point for this review id # 20029? Yes.

Yes { do nothing }
No { Add a point }

...you get the idea -- use a sql table for this.

phpisuber01
  • 7,585
  • 3
  • 22
  • 26
  • Several different actions can be done but all stored in the same actions table, so every review written, comment left, purchase made, goes into the actions table with a unique id and the appropriate points, only problem is that the id is an auto increment field so refreshing just adds the same action but with new ID, how would you work around that or should I change that up in the DB – forevermetal02 Oct 19 '12 at 20:18