Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $connection = mysqli_connect("localhost", "root", "", "authdb");
- if ($_SERVER['REQUEST_METHOD'] === "POST") {
- $username = mysqli_real_escape_string($connection, $_POST['username']);
- $pass = mysqli_real_escape_string($connection, $_POST['password']);
- $email = mysqli_real_escape_string($connection, $_POST['email']);
- if ($connection) {
- $query = " SELECT username, password ,email FROM users WHERE username = '$username' AND password = '$pass' ";
- $res = mysqli_query($connection, $query);
- $data = mysqli_fetch_assoc($res);
- if ($username === $data['username'] && $pass === $data['password']) {
- echo 'True!';
- } else {
- echo 'username not found.';
- }
- } else {
- die("Connection Failed!");
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Login</title>
- <link rel="stylesheet" type="text/css" href="./css/style.css">
- <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,700" rel="stylesheet">
- </head>
- <body>
- <div id = "login-page">
- <div id = "form-box">
- <form class = "login-form" method="POST" action="login.php">
- <input type = "text" name="username" placeholder = "username" />
- <input type = "password" name="password" placeholder = "password" />
- <input type = "email" name="email" placeholder = "password" />
- <button>LOGIN</button>
- <p class = "message">Not registered? <a href = "#">Create an account</a></p>
- </form>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement