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
| <?php
// On démarre la session
session_start();
$loginOK = false; // cf Astuce
//connexion à la base
$db = mysql_connect('localhost','root','') or die ('erreur de connexion');
//sélection de la base
mysql_select_db('nom',$db);
$sql = "SELECT callsign, password FROM members WHERE callsign = '$login'";
$req = mysql_query($sql) or die('Erreur SQL');
if ( mysql_num_rows($req) > 0 ) {
$data = mysql_fetch_assoc($req);
if ($password == $data['password']) {
$loginOK = true;
}
}
}
if ($loginOK) {
$_SESSION['callsign'] = $data['callsign'];
}
else {
echo "Une erreur est survenue, veuillez réessayer !";
}
mysql_close()
?> |
Partager