But I just wanted it to check once and not every time I refresh the page.
A very basic way, would you store a variable in the client session :
$selectPost = selectPos();
//select number of posts
if($selectPost == 2 && !isset($_SESSION['recebeu_bonus'])) {
update_Post_Bonus($db, $steamid);
$_SESSION['recebeu_bonus'] = true;
}
If you are not using a session in your project, be sure to add start_session()
at the start of your script .
Session Usage Guide : PHP: > Session Variables
Another option if you have some login system , would be to create a table in your database that stores the User ID when receiving the bonus. Hence, just create a function that checks if the user has received the bonus and put it in the condition:
$selectPost = selectPos();
//select number of posts
if($selectPost == 2 && !recebeu_bonus($id_do_usuario)) {
update_Post_Bonus($db, $steamid);
registrar_bonus($id_do_usuario); // função para registrar a ID do usuário na tabela do bônus no banco de dados
}
We need to develop the functions to check if the user has received the bonus and to register the user upon receiving the bonus according to their project / database. And if there are several bonuses in your project, you can create a table for each bonus and insert a column in the table to register the bonus id next to the user id . p>