I already searched the site here and did not find anything that could really help me. I think some of you can help me.
This is the following, I created a link that gets the 'x' post ID via GET and with each click on that link an UPGRADE is performed in the DB where it takes the previous number of clicks and counts +1, but if I clicking countless times on that link will count countless clicks.
I would like to know how do I store the click of that particular user for 24 hours?
The code that I use to upgrade my clicks is below
<?php
$ID = filter_input(INPUT_GET, 'ID');
if(empty($ID) || !is_numeric($ID)){
echo '<script type="text/javascript">location="../";</script>';
}else{
$seleciona = $pdo->prepare("SELECT * FROM postagens WHERE ID = ? LIMIT 1");
$seleciona->bindValue(1, $ID, PDO::PARAM_INT);
$seleciona->execute();
$dados = $seleciona->fetchObject();
$n_status = $dados->CLIQUES + 1;
if($dados){
$stmte = $pdo->prepare("UPDATE postagens SET CLIQUES = :1 WHERE ID = :2");
$stmte->bindParam(":1", $n_status , PDO::PARAM_INT);
$stmte->bindParam(":2", $ID , PDO::PARAM_STR);
$executa = $stmte->execute();
if($executa){
echo '<script type="text/javascript">location="http://'.$dados->LINK.'";</script>';
}else{
echo 'Erro ao inserir os dados';
}
}
}
?>