Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <?php session_start(); ?>
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>SQL Injection Sample</title>
  7. </head>
  8. <body>
  9. <link href="css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
  10. <link href="css/custom.css" rel="stylesheet">
  11. <script src="js/bootstrap.min.js"></script>
  12. <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  13.  
  14. <div class="sidenav">
  15. <div class="login-main-text">
  16. <h2>Application<br> Login Page</h2>
  17. <p>Login or register from here to access.</p>
  18. </div>
  19. </div>
  20. <div class="main">
  21. <div class="col-md-6 col-sm-12">
  22. <div class="login-form">
  23. <form method="post" action="login.php">
  24. <div class="form-group">
  25. <label>User Name</label>
  26. <input type="text" class="form-control" placeholder="User Name" name="username">
  27. </div>
  28. <div class="form-group">
  29. <label>Password</label>
  30. <input type="password" class="form-control" placeholder="Password" name="password">
  31. </div>
  32. <button type="submit" class="btn btn-black" name="loginBtn">Login Here</button>
  33. <a class="btn btn-secondary" href="register.php">Go to Register Page</a>
  34. </form>
  35. <?php
  36. if(isset($_POST['loginBtn'])) {
  37. $conn = mysqli_connect("localhost", "root", "", "hacking_db");
  38. if(!$conn){
  39. die("connection error");
  40. }
  41.  
  42. $username = $_POST['username'];
  43. $password = $_POST['password'];
  44.  
  45. if(trim($username) == '') {
  46. echo "Username can not be left empty!";
  47. }
  48. else if(trim($password) == '') {
  49. echo "Password can not be left empty!";
  50. }
  51.  
  52. else {
  53. $verify_sql = "select * from `users` where username='$username' and password='$password' LIMIT 1";
  54. $result = mysqli_query($conn,$verify_sql);
  55.  
  56. $row = mysqli_fetch_array($result);
  57.  
  58. if(mysqli_num_rows($result) > 0){
  59. $_SESSION['session_username'] = $username;
  60. header('Location: dashboard.php');
  61. }
  62. else {
  63. echo "No user exists, please register to continue!";
  64. }
  65. }
  66. }
  67. ?>
  68. </div>
  69. </div>
  70. </div>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement