login.php


SUBMITTED BY: 42pi

DATE: April 17, 2021, 1:51 p.m.

UPDATED: April 17, 2021, 1:52 p.m.

FORMAT: Text only

SIZE: 1.6 kB

HITS: 473

  1. <?php
  2. require('/include/db.php');
  3. $error="";
  4. if(isset($_POST['submit'])){
  5. if(empty($_POST['username'] || empty($_POST['password']))){
  6. $error="Username or password is invalid";
  7. }
  8. else{
  9. $username = $_POST['username'];
  10. $pass = $_POST['password'];
  11. $query = mysqli_query($conn, "INSERT INTO `users` (`id`, `username`, `password`) VALUES (NULL, '$username', '$pass');");
  12. $rows = mysqli_num_rows(mysqli_query($conn, "SELECT * FROM users WHERE password='$pass' AND username='$username'"));
  13. if($rows == 1){
  14. header("Location: Login.php");
  15. }
  16. else{
  17. $error = "Registration Unsuccessful";
  18. echo "".$error;
  19. }
  20. mysqli_close($conn);
  21. }
  22. }
  23. ?>
  24. <!DOCTYPE html>
  25. <html>
  26. <head>
  27. <meta charset="utf-8" />
  28. <title>Login</title>
  29. <meta name="viewport" content="width=device-width, initial-scale=1">
  30. <link rel="stylesheet" type="text/css" media="screen" href="login.css"/>
  31. </head>
  32. <body>
  33. <section>
  34. <div class="layer"></div>
  35. <div class="container">
  36. <div class="login-form">
  37. <h1>SIGN UP</h1>
  38. <form action="" method="post">
  39. <input type="text" name="username" id="username" placeholder="username/e-mail">
  40. <input type="password" name="password" id="password" placeholder="password">
  41. <input type="submit" name="submit" value="SIGN UP">
  42. </form>
  43. <a href="Login.php">BACK<a>
  44. </div>
  45. </div>
  46. </section>
  47. </body>
  48. </html>

comments powered by Disqus