Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. if($_SERVER['REQUEST_METHOD'] == 'POST') {
  4. $usuario = $_POST['usuario'];
  5. $senha = $_POST['senha'];
  6.  
  7. $root = 'root';
  8. $password= '1111';
  9. $conn = new PDO('mysql:host=localhost;dbname=fail', $root, $password);
  10.  
  11. $sql = "SELECT * FROM login WHERE usuario=:usuario AND senha=:senha;";
  12.       $stmt = $conn->prepare( $sql );
  13.       $stmt-> bindParam( ':usuario', $usuario );
  14.       $stmt-> bindParam( ':senha', $senha );    
  15.       $stmt->execute();
  16.       $result = $stmt->fetchAll();
  17.  
  18. if (count($result)) {
  19.     header("location: admin2.php");
  20. }
  21. else {
  22.     throw new Error($stmt->errorInfo());
  23.    
  24. }
  25. }
  26.  
  27. ?>
  28.  
  29. <!DOCTYPE html>
  30. <html>
  31. <head>
  32. <title>SQL Injection</title>
  33. </head>
  34. <body>
  35. <form action="index2.php" method="POST">
  36. <h1>SQL Injection - Teste</h2><br>
  37. Usuário:<br>
  38. <input type="text"
  39. name="usuario"<br><br>
  40. Senha:<br>
  41. <input type="text"
  42. name="senha"<br><br>
  43. <input type="submit" value="Login">
  44. </Form>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement