Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. $connection = mysqli_connect("localhost", "root", "", "authdb");
  3. if ($_SERVER['REQUEST_METHOD'] === "POST") {
  4.  
  5. $username = mysqli_real_escape_string($connection, $_POST['username']);
  6. $pass = mysqli_real_escape_string($connection, $_POST['password']);
  7. $email = mysqli_real_escape_string($connection, $_POST['email']);
  8.  
  9. if ($connection) {
  10.  
  11. $query = " SELECT username, password ,email FROM users WHERE username = '$username' AND password = '$pass' ";
  12. $res = mysqli_query($connection, $query);
  13. $data = mysqli_fetch_assoc($res);
  14.  
  15. if ($username === $data['username'] && $pass === $data['password']) {
  16. echo 'True!';
  17. } else {
  18. echo 'username not found.';
  19. }
  20. } else {
  21. die("Connection Failed!");
  22. }
  23. }
  24. ?>
  25.  
  26. <!DOCTYPE html>
  27. <html lang="en">
  28.  
  29. <head>
  30. <title>Login</title>
  31. <link rel="stylesheet" type="text/css" href="./css/style.css">
  32. <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,700" rel="stylesheet">
  33. </head>
  34.  
  35. <body>
  36. <div id = "login-page">
  37. <div id = "form-box">
  38. <form class = "login-form" method="POST" action="login.php">
  39. <input type = "text" name="username" placeholder = "username" />
  40. <input type = "password" name="password" placeholder = "password" />
  41. <input type = "email" name="email" placeholder = "password" />
  42. <button>LOGIN</button>
  43. <p class = "message">Not registered? <a href = "#">Create an account</a></p>
  44. </form>
  45.  
  46. </div>
  47. </div>
  48. </body>
  49.  
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement