login.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.utils.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. $error = '';
  5. // Использование
  6. $redirect_url = getSafeRedirectUrl(DEFAULT_PAGE);
  7. if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
  8. $login = trim($_POST['login']);
  9. $password = trim($_POST['password']);
  10. // validate if login is empty
  11. if (empty($login)) {
  12. $error .= '<p class="error">'.WEB_msg_login_hint.'.</p>';
  13. }
  14. // validate if password is empty
  15. if (empty($password)) {
  16. $error .= '<p class="error">'.WEB_msg_password_hint.'.</p>';
  17. }
  18. if (empty($error)) {
  19. if (login($db_link)) {
  20. $redirect_url = urldecode($redirect_url);
  21. header("Location: $redirect_url");
  22. }
  23. }
  24. }
  25. ?>
  26. <!DOCTYPE html>
  27. <html>
  28. <head>
  29. <title><?php echo WEB_site_title; ?> login</title>
  30. <link rel="stylesheet" type="text/css" href="/css/<?php echo HTML_STYLE.'.css'; ?>">
  31. <link rel="stylesheet" type="text/css" href="/login.css" >
  32. <meta http-equiv="content-type" content="application/xhtml+xml" />
  33. <meta charset="UTF-8" />
  34. </head>
  35. <body>
  36. <div class="login">
  37. <h1><?php echo WEB_msg_login; ?></h1>
  38. <form action="" method="post">
  39. <label for="username">
  40. <i class="fas fa-user"></i>
  41. </label>
  42. <input type="text" name="login" placeholder="<?php echo WEB_msg_username; ?>" id="login" required autofocus>
  43. <label for="password">
  44. <i class="fas fa-lock"></i>
  45. </label>
  46. <input type="password" name="password" placeholder="<?php echo WEB_msg_password; ?>" id="password" required>
  47. <input type="hidden" name="redirect_url" value="<?php print htmlspecialchars($redirect_url); ?>">
  48. <input type="submit" name="submit" value="<?php echo WEB_btn_login; ?>">
  49. </form>
  50. </div>
  51. </body>
  52. </html>