<?php


$bugun = date("d");
$ay = date("m");
$yil = date("Y");
$ip = $_SERVER["REMOTE_ADDR"];
$bugunGiris = $db->query("SELECT * FROM hit WHERE ip='" . $ip . "' AND gun='" . $bugun . "'")->rowCount();
if ($bugunGiris != 0) {
    $al = $db->query("SELECT * FROM hit WHERE ip = '" . $ip . "' AND gun = '" . $bugun . "'")->fetch(PDO::FETCH_ASSOC);
    $sorgu = $db->prepare("UPDATE hit SET\r\n\t\t\tsayac\t= ?,\r\n\t\t\tsimdi\t= ?\r\n\t\t\tWHERE id = ?");
    $guncelle = $sorgu->execute([$al["sayac"] + 1, time(), $al["id"]]);
} else {
    $sorgu = $db->prepare("INSERT INTO hit SET\r\n\t\tgun \t= ?,\r\n\t\tay\t\t= ?,\r\n\t\tyil \t= ?,\r\n\t\tsimdi\t= ?,\r\n\t\tsayac \t= ?,\r\n\t\tip\t\t= ?");
    $Ekle = $sorgu->execute([$bugun, $ay, $yil, time(), "1", $ip]);
}

?>