Advertisement
Timothy60

Untitled

May 1st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 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. }
  11. catch(Exception $e){
  12. die('Erreur : '.$e->getMessage());
  13. }
  14.  
  15. $result = $bdd->prepare("SELECT password FROM Users WHERE login = :user");
  16. $result->execute(array(':user'=>$username));
  17. $data = $result->fetch();
  18. if(password_verify($password, $data['password'])){
  19. $_SESSION['login'] = $username;
  20. header("Location: calendar_custom.php");
  21. exit;
  22. }
  23. else{
  24. $_SESSION['error'] = "LOGIN or PASSWORD is invalid.";
  25. header("Location: affiche.php");
  26. exit;
  27. }
  28. $result->closeCursor();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement