Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_host = 'localhost';
- $db_user = 'root';
- $db_pass = null;
- $db_name = 'simple';
- $conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
- if ($conn->connect_error) {
- die('Connection failed: ' . $conn->connect_error);
- }
- if ($_SERVER['REQUESTED_METHOD'] == 'POST') {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $sql = "SELECT username, password FROM users WHERE username = $username LIMIT 1";
- $user = $conn->query($sql);
- if ($user) {
- if (password_verify($password, $user['password'])) {
- echo 'Sekmingai prisijungete';
- } else {
- echo 'Blogi duomenys';
- }
- } else {
- echo 'Blogi duomenys';
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <form method="POST">
- <label for="username"></label>
- <input id="username" type="text" name="username">
- <label for="password"></label>
- <input id="password" type="password" name="password">
- <button>Login</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement