Advertisement
Guest User

Untitled

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