Hello, the next I made a system that works, but I'm sure it's safe to use it to make sure it's safer or at least try to get it. I'm using a function that only reads numbers in mysql , but I'm still a beginner and would like a second opinion about it.
Can anyone tell me if it's safe or is there something else to make sure?
Code:
$id = $_COOKIE["id"]; //Nome do cookie
$novoId = "$cont[id]"; // Novo id, value exemplo "1,2,3,4" adiciona novo valor apos virgula
if (!preg_match("/\b{$novoId}\b/", $id)) {
setcookie("id", $id .= "{$novoId},");
}
$historico = explode(",", $id);
$histanime = array_filter($historico, function($value) {
/* Retorna apenas os números inteiros */
return is_numeric($value);
});
if(($quantidade = count($histanime)) > 30){
$histanime = array_slice($histanime, $quantidade - 30, 30);
}
$ids5 = implode(",", $histanime) ;
and the query in mysql is done with while :
$cont = mysql_query("SELECT title,titulo2,url,imagen FROM 'lista' WHERE aid IN($ids5)");
while (list($title, $titulo2, $url, $Imagen) = mysql_fetch_array($cont))