Advertisement
Timothy60

Untitled

May 1st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $username = htmlspecialchars($_POST['login'],ENT_QUOTES,ISO-8859-15);
  6. $password = htmlspecialchars($_POST['password'],ENT_QUOTES,ISO-8859-15);
  7.  
  8. try{
  9. $bdd = new PDO('mysql:host=localhost;dbname=calendar;charset=utf8', 'root', 'isencir');
  10. } catch(PDOException $e) {
  11.  
  12. }
  13. catch(Exception $e){
  14. die('Erreur : '.$e->getMessage());
  15. }
  16.  
  17. $result = $bdd->prepare("SELECT login,password FROM Users WHERE login = :user");
  18. $result->execute(array(':user'=>$username));
  19. $data = $result->fetch();
  20. if(password_verify($password, $data['password'])){
  21. $_SESSION['login'] = $data['login'];
  22. if($_SESSION['login'] ==='customer'){
  23. header("Location: calendar_custom.php");
  24. exit;
  25. }
  26. else if($_SESSION['login']==='organizer'){
  27. header("Location: essai_affich_calendar.php");
  28. exit;
  29. }
  30. }
  31. else{
  32. $_SESSION['error'] = "LOGIN or PASSWORD is invalid.";
  33. header("Location: affiche.php");
  34. exit;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement