Question

Does anybody knows how to implement something into a website written in PHP, similar to the Woot-badge and the Fanatic-badge on stack overflow? I want to reward my users if they visit my site everyday for 75 days, without days they don't visit it. My site uses sessions for log ins. And I use a MySQL database.

The users table now looks like this:

COLUMN NAME        TYPE
id                 integer
username           varchar
password           varchar
email              varchar
(7 columns with privacy settings) integer
lastvisit          integer
lastlogin          integer
Was it helpful?

Solution

Pseudo-code:

switch last visit
   case yesterday
      increment counter by 1
      set last visit to today
      if counter == 75
          award badge
   case more than a day ago
      set counter to zero
      set last visit to today
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top