1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test connexion automatique</title>
</head>
<body>
<?php
if (isset($_COOKIE['connexion_automatique']))
{
if($_COOKIE['connexion_automatique'] == 1)
{
$ID = intval($_COOKIE['ID']);
// Vérification des identifiants
try
{
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
//Ici on va chercher les données du membre
$reponse = $bdd->query('SELECT pseudo FROM membres WHERE ID='.$ID' ');
while($donnees = $reponse ->fetch())
{
$_SESSION['pseudo'] = $donnees['pseudo'];
session_start();
header('location: page.php');
}
}
}
?>
</body>
</html> |
Partager