Advertisement
Guest User

Untitled

a guest
May 27th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. require_once('inc/init.inc.php');
  3.  
  4. if (isset($_POST['connexion']) && $_POST['connexion'] == 'Connexion' && $_POST['statut'] == 0) {
  5.  
  6. $userLogged = false;
  7. $isAdmin = false;
  8. $email = $_POST['mail'];
  9. $password = md5($_POST['mdp']);
  10. $userId = null;
  11. $userType = "";
  12. echo 'mail posté : ' . $_POST['mail'] . '<br />';
  13. echo 'mdp posté : ' . $password . '<br />';
  14.  
  15.  
  16.  
  17. $resultat = $mysqli->query('SELECT * FROM membres_juniors WHERE email_parent is not NULL');
  18. $data = $resultat->fetch_array(MYSQLI_ASSOC);
  19.  
  20. if(isset($data)){
  21.  
  22. if($data['email_parent'] === $email){
  23.  
  24. if($data['mdp_parent'] === $password){
  25.  
  26. $userLogged = true;
  27. $userType = "junior";
  28. $userId = $datas['id_junior'];
  29. $isAdmin = true;
  30.  
  31. }
  32. }
  33. }
  34.  
  35. $resultatgp = $mysqli->query('SELECT * FROM membres_seniors WHERE email_senior is not NULL');
  36. $datasgp = $resultatgp->fetch_array(MYSQLI_ASSOC);
  37. if(isset($datasgp)){
  38.  
  39. if($datasgp['email_senior'] === $email){
  40.  
  41. if($datasgp['mdp_senior'] === $password){
  42.  
  43. $userLogged = true;
  44. $userType = "senior";
  45. $userId = $datasgp['id_senior'];
  46. $isAdmin = true;
  47.  
  48. }
  49. }
  50. }
  51.  
  52. $resultatins = $mysqli->query('SELECT * FROM membres_institutions WHERE email_institution is not NULL');
  53. $datasins = $resultatins->fetch_array(MYSQLI_ASSOC);
  54.  
  55. if(isset($datasins)){
  56.  
  57. if($datasins['email_institution'] === $email){
  58.  
  59. if($datasins['mdp_institution'] === $password){
  60.  
  61. $userLogged = true;
  62. $userType = "institution";
  63. $userId = $datasins['id_institution'];
  64. $isAdmin = true;
  65. }
  66. }
  67. }
  68.  
  69. if ($userLogged == true) {
  70. session_start();
  71. # l'utilisateur existe et a entrée les bons logs
  72. $_SESSION['userId'] = $userId;
  73. $_SESSION['userEmail'] = $email;
  74. $_SESSION['userType'] = $userType;
  75.  
  76. //echo 'SUCCESS';
  77.  
  78. }else{
  79.  
  80. # on sait que l'utilisateur nest pas connecté du tout
  81. $_SESSION['userId'] = null;
  82. $_SESSION['userType'] = null;
  83. $_SESSION['userEmail'] = null;
  84.  
  85. }
  86.  
  87. if ($isAdmin == true ) {
  88. # l'utilisateur est un admin
  89. $_SESSION['statut'] == 1;
  90. header('Location: admin.php');
  91. }else{
  92. header('Location: profil.php');
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement