Advertisement
Timothy60

Untitled

May 1st, 2018
92
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);
  6. $password = htmlspecialchars($_POST['password'],ENT_QUOTES);
  7.  
  8. try{
  9. $bdd = new PDO('mysql:host=localhost;dbname=calendar;charset=utf8', 'root', 'isencir');
  10. $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. } catch(PDOException $e) {
  12.  
  13. }
  14. catch(Exception $e){
  15. die('Erreur : '.$e->getMessage());
  16. }
  17.  
  18. $result = $bdd->prepare("SELECT password FROM Users WHERE login = :username");
  19. $result->bindParam(':username',$username);
  20. $result->execute();
  21. $data = $result->fetch(PDO::FETCH_ASSOC);
  22. if(password_verify($password, $data['password'])){
  23. if($username =='customer'){
  24. header("Location: calendar_custom.php");
  25. exit;
  26. }
  27. else if($username=='organizer'){}
  28. header("Location: essai_affich_calendar.php");
  29. exit;
  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