authenticate.php 640 B

123456789101112131415161718192021
  1. <?php
  2. use App\MyUser;
  3. $login = htmlspecialchars($_POST['login']);
  4. $passwd = htmlspecialchars($_POST['passwd']);
  5. try {
  6. $user = new MyUser($login, $passwd);
  7. if (!$user->exists()) {
  8. header('Location: signin');
  9. $_SESSION['message'] = 'Bad password';
  10. exit();
  11. }
  12. $_SESSION['login'] = $login;
  13. header('Location: admin/welcome');
  14. exit();
  15. }
  16. catch(Exception $e) {
  17. $_SESSION['message'] = $e->getMessage();
  18. header('Location: signin');
  19. exit();
  20. }