Run update query once and stop user refresh page

Started by Kustff, October 31, 2017, 10:35:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kustff

#4
Quote from: whocares on October 31, 2017, 03:12:27 PM
Create a tinyint field in the users table named bnschk or something and change the code to

Code (php) Select
if ($act == '31' && date('m') == '10' && date('d') == '31') {

  mysql_query("UPDATE users SET seedbonus = seedbonus + 100, bnschk = 1 WHERE bnschk = 0 AND id=".sqlesc($CURUSER['id']));

  errmsg("info", "Yey!", "You just get 100 bonuspoints!");


} else {

  errmsg("error", "You can't get bonuspoints", "");
}

stdfoot();


This will still tell them everytime they refresh that they're getting the points but only give them once.

Thanks for your response. Can you give some help to this user field?  :) And there is no way to do that users get an error when they trying to reload page multiple times? And if I do these more like then updates (different days etc..) user can't get these points because bnschk is set to "1" in day 31. I mean if there is

if day 1 get points if click, if day 2 get points if click etc...

whocares

Create a tinyint field in the users table named bnschk or something and change the code to

Code (php) Select
if ($act == '31' && date('m') == '10' && date('d') == '31') {

  mysql_query("UPDATE users SET seedbonus = seedbonus + 100, bnschk = 1 WHERE bnschk = 0 AND id=".sqlesc($CURUSER['id']));

  errmsg("info", "Yey!", "You just get 100 bonuspoints!");


} else {

  errmsg("error", "You can't get bonuspoints", "");
}

stdfoot();


This will still tell them everytime they refresh that they're getting the points but only give them once.
Unless stated otherwise code is untested

Diablo999

Why don't you just add the 100BP through the add massbonus page?
You probably need to add a check in the DB, so it stores when a user gets the 100BP and add the check to the script. Then you have to clear the check for later use without a small cleanup, which you can run the day after.

I would prefer to add them myself each month or make a cleanup for it.

Kustff

So when user open link page.php?act=31 user get 100 bonuspoints if day is 31, but otherwise user get error msg. My problem here is that user can update page so many times he/she wants so how I can protect that update query that runs once?

Code (php) Select

if ($act == '31' && date('m') == '10' && date('d') == '31') {

  mysql_query("UPDATE users SET seedbonus = seedbonus + 100 WHERE id=".sqlesc($CURUSER['id']));

  errmsg("info", "Yey!", "You just get 100 bonuspoints!");


} else {

  errmsg("error", "You can't get bonuspoints", "");
}

stdfoot();