Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <?php
- session_start();
- include "funkcije.php";
- if (isset($_SESSION['loggedin'])) {
- header('Location: ./index.php');
- }
- ?>
- <form method="POST" action="login.php">
- <ul>
- <li>
- Username: <input type="text" name="username" >
- </li>
- <li>
- Password <input type="password" name="password" >
- </li>
- <li>
- <input type="submit" name="submit" value="Log In" >
- </li>
- </ul>
- </form>
- <?php
- if (isset($_POST['submit'])) {
- if (!empty($_POST['username']) && !empty($_POST['password'])) {
- @$user = htmlspecialchars($_POST['username'], ENT_QUOTES, 'UTF-8');
- @$pass = htmlspecialchars($_POST['password'], ENT_QUOTES, 'UTF-8');
- $query = "SELECT * FROM `users` WHERE username='" . mysqli_real_escape_string($con, $user) . "'";
- if ($result = @mysqli_query($con, $query)) {
- while ($row = @mysqli_fetch_assoc($result)) {
- $sifra = $row['password'];
- if (password_verify($pass, $sifra)) {
- $_SESSION['loggedin'] = time().$user;
- $_SESSION['user'] = $user;
- header('Location: ./index.php');
- } else {
- die("Sifra nije dobra.");
- }
- }
- } else {
- echo "Nepostojeci korisnik.";
- }
- } else {
- echo "Sva polja su obavezna";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement