Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('basededonnees.php');
- $login = $_POST['login'];
- $password =$_POST['password'];
- if (!empty($user) && !empty($password)){
- $req = $connect->prepare('SELECT id,user,password,nom,prenom,age,prof FROM user WHERE user=:user AND password=:password');
- $req->execute(array('user' => $user,'password' => md5($password)));
- $resultat = $req->fetch(PDO::FETCH_ASSOC);
- $req->closeCursor();
- if ($resultat){
- echo'Erreur connexion';
- exit();
- }
- else{
- session_start();
- $_SESSION['id'] = $resultat['id'];
- $_SESSION['user'] = $user;
- $_SESSION['nom']=$resultat['nom'];
- $_SESSION['prenom']= $resultat['prenom'];
- $_SESSION['prof']=$resultat['prof'];
- if($_SESSION['prof']==1){
- header('Location: /acces-prof/index.php');
- exit();
- }
- if($_SESSION['prof']==0){
- header('Location: /acces-eleves/index.php');
- exit();
- }
- }
- }
- else {
- header('Location: ../index.php?erreur=1');
- exit();
- }
- ?>
Add Comment
Please, Sign In to add comment