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
|
<?
include"config-inc.php";
session_start() ;
//Connection à la BD et sélection de la base "utilisateurs"
mysql_connect($db_host,$db_user,$db_pass) or die("Unable to connect to database");
mysql_select_db($db_db) or die( "Unable to select database");
//Requêtes mySQL pour établir la validation.
if((isset($_POST['pseudo'])) && (isset($_POST['pwd']))) {
$pseudo=$_POST['pseudo'];
$pwd=$_POST['pwd'];
}
$query = " SELECT * FROM users WHERE pseudo='$pseudo' AND pwd='$pwd' ";
//Exécution de la requête mySQL et
//affectation du nombre de rangés valides dans la table.
//********************************************
$result = mysql_query($query) or die('error making query');
$affected_rows = mysql_num_rows($result);
//Si il y a un enregistrement, la connexion est valide sinon invalide.
//*****************************************************
if($affected_rows >= 1 ){
//requete SQL me permetttant de definir les sections
//*****************************************************
$perso = mysql_query (" SELECT * FROM users WHERE pseudo='$pseudo'AND section='amis'");
$admin = mysql_query (" SELECT * FROM users WHERE pseudo='$pseudo'AND section='admin'");
$esiea = mysql_query( " SELECT * FROM users WHERE pseudo='$pseudo'AND section='esiea'");
if($row1 = mysql_fetch_array($perso, MYSQL_NUM)){
$_SESSION['perso'] = 'amis';
$_SESSION['pseudo']= $pseudo;
mysql_query("update connecter set connect = 1 where pseudo='$pseudo'");
$url = '../deuil/persoIndex.php';
}
if($row2 = mysql_fetch_array($esiea, MYSQL_NUM)){
$_SESSION['esiea'] = 'esiea';
$_SESSION['pseudo']= $pseudo;
mysql_query("update connecter set connect = 2 where pseudo='$pseudo'" );
$url = '../esiea/esieaIndex.php';
}
if($row3 = mysql_fetch_array($admin, MYSQL_NUM)){
$_SESSION['admin'] = 'admin';
$_SESSION['pseudo']= $pseudo;
$url = '../admin/adminIndex.php';
mysql_query("update connecter set connect = 3");
}
//ajoute l'utilisateur à une variable de session.
//************************************
//$_SESSION['usernameAd'] = $pseudo;
@header("Location:$url");
mysql_close($db_db);
exit();
session_destroy();
}
else {
@header("Location: auth.php");
exit();
}
?> |
Partager