Advertisement
Guest User

Untitled

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