1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <?php
$ip=$_SERVER['REMOTE_ADDR'];
$cejour=date("d/m/Y");
$year=date("Y");
$mois=date("m");
$jour=date("d");
//echo "<script>alert( '$cejour');</script>";
//Connection
try {
$pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
$bdd=new PDO('mysql:host=localhost;dbname=matable','','',$pdo_options);
} catch (Exception $e) {
die('Erreur:'.$e->getMessage());
}
// On ajoute une entrée dans la table visites
$req = $bdd->prepare('INSERT INTO visites(ip_visite, ladate) VALUES(:ip_vis, :dat_vis)');
$req->execute(array(
'ip_vis' => $ip,
'dat_vis' => $cejour ));
$bdd->closeCursor();
?> |