Advertisement
Guest User

Vuln login

a guest
Dec 4th, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["username"]) && isset($_POST["password"]))
  3. {
  4. $link = mysqli_connect("localhost", "root", "") or $error="Server error";
  5. mysqli_select_db($link,"test_vuln");
  6. $username = $_POST["username"];
  7. $password = $_POST["password"];
  8. $query = "SELECT user, password FROM users WHERE user='$username' AND password='$password'";
  9. $result = mysqli_query($link, $query);
  10. if(mysqli_error($link))
  11. $error="Query failed";
  12. if(!mysqli_num_rows($result))
  13. $error="Wrong username o password ";
  14. else
  15. header("Location: index.php");
  16. mysqli_close($link);
  17. }
  18. ?>
  19. <body>
  20. <div class="bs-component">
  21. <form action="Login.php" method="post">
  22. <input type="text" placeholder="Username" class="form-control" id="inputDefault" name ="username"/><br>
  23. <input type="password" placeholder="Password" class="form-control" id="inputPassword" name="password"/><br>
  24. <input type="submit" class="btn btn-primary" value="Login"/><br>
  25. <label><?php if(isset($error)) {echo $error;} ?></label>
  26. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement