Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include_once (__DIR__ . '/functions.php'); //подключаем файл с функциями
  5.  
  6.  
  7. if ( null !== getCurrentUser() ) { //Если пользователь вошёл, то редирект на главную страницу
  8. header('Location: /index.php');
  9. exit;
  10.  
  11. } else {
  12. if ( isset( $_POST['login'] ) ) {
  13. if ( isset( $_POST['password'] ) ) { //Если введены данные в форму входа
  14. if ( checkPassword($_POST['login'], $_POST['password']) ) {
  15. $_SESSION['username'] = $_POST['login']; //помечаем клиента
  16. header('Location: /index.php');
  17. exit;
  18. }
  19. }
  20. }
  21. }
  22. ?>
  23. <html>
  24. <head>
  25. <title>Авторизация</title>
  26. </head>
  27. <body>
  28. <h4>Авторизация</h4>
  29. <!--. 3. Форма входа на сайт-->
  30. <form action="/login.php" method="post">
  31. Логин: <input type="text" name="login">
  32. Пароль: <input type="password" name="password">
  33. <button type="submit">Войти</button>
  34. </form>
  35. <p>Введите логин и пароль</p>
  36. <br>
  37. <a href="/gallery.php">Перейти в фотогалерею без авторизации<br>(Добавление фото возможно только для авторизованных пользователей)</a>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement