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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| <?php
// Etablissement de la connexion avec le serveur
$connexion=mysql_connect("localhost","root");
// Test de la connexion
if (!$connexion) {
echo "La connexion au serveur n'a pu être établie<BR>";
exit;
}
//Test de l'accès à la base
if (!mysql_select_db("c.h.a.r.m.",$connexion)) {
echo "L'accès à la base n'est pas permis<BR>";
exit;
}
if(isset ($_POST) && !empty($_POST['identifiant']) && !empty($_POST['login'])) {
$login=$_POST['identifiant'];
$pwd=$_POST['login'];
$adh="select NomAdh from adherents where NomAdh='".$login."'";
$emp="select NomEmp from employes where NomEmp='".$login."'";
if (!empty($adh)) {
// on recupère le password de la table qui correspond au login du visiteur
$sql = "select MotDePasseAdh, NomAdh, PrenomAdh from adherents where NomAdh='".$login."'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_assoc($req);
if($data['MotDePasseAdh'] != $pwd) {
echo '<br>Mauvais identifiant ou mot de passe.<br> Merci de recommencer';
}
else {
session_start();
$_SESSION['NomAdh'] = $login;
header ("location: accueil_utilisateur.php");
}
}
elseif (!empty($emp)) {
// on recupère le password de la table qui correspond au login du visiteur
$sql = "select MotDePasseEmp, NomEmp, PrenomEmp from employes where NomEmp='".$login."'";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$data = mysql_fetch_assoc($req);
if($data['MotDePasseEmp'] != $pwd) {
echo '<br>Mauvais identifiant ou mot de passe.<br> Merci de recommencer';
}
else {
session_start();
$_SESSION['NomEmp'] = $login;
header ("location: accueil_employe.php");
}
}
}
?> |
Partager