Guest User

Untitled

a guest
May 24th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <html>
  2. <body>
  3. <h3>CHECK MD5</h3>
  4. <form method="post" id="getpass" action="/snir.php">
  5. <input type="text" name="md5" size="120" value=''>
  6. <input type="submit" name="Check" value='Check'>
  7. <h3> ADD PASSWORD TO DB </h3>
  8. <form id="addpass" method="post" action="/snir.php">
  9. <input type="text" name="pass" size="120" value=''>
  10. <input type="submit" name="Add" value='Add'>
  11. </form>
  12. </body>
  13. </html>
  14.  
  15. <?php
  16.  
  17. //MY SQL Settings
  18. $host= "localhost";
  19. $user= "root";
  20. $pass= "";
  21. $dbname="passwords";
  22.  
  23.  
  24. //SQL Connection
  25. $con = mysql_connect($host,$user,$pass);
  26. if (!$con)
  27. {
  28. die('Could not connect: ' . mysql_error());
  29. }
  30. mysql_select_db($dbname, $con);
  31.  
  32. //SELECT PASSWORDS
  33. $result = mysql_query("SELECT * FROM psw");
  34.  
  35. //LOOP ALL RESULTS
  36. $found=0;
  37. while($row = mysql_fetch_array($result))
  38. {
  39. if(ISSET($_POST["md5"])&& md5($row['pass'])==$_POST["md5"])
  40. {
  41. $found=1;
  42. echo ("Result=");
  43. echo ($row['pass']);
  44. echo ("<br>");
  45. }
  46. }
  47.  
  48. if($found==0&&ISSET($_POST["md5"])&&$_POST["md5"]!=null)
  49. echo ("NOT FOUND");
  50.  
  51. if(ISSET($_POST["pass"])&&$_POST["pass"]!=null)
  52. {
  53. $error=0;
  54. $result = mysql_query("SELECT * FROM psw");
  55. while($row = mysql_fetch_array($result))
  56. {
  57. if($row['pass']==$_POST["pass"])
  58. {
  59. $error=1;
  60. break;
  61. }
  62. }
  63. if($error==0)
  64. {
  65. $add = "INSERT INTO psw (pass) VALUES ('$_POST[pass]')";
  66. mysql_query($add,$con);
  67. echo "Added MD5=";
  68. echo md5($_POST["pass"]);
  69. }
  70. if($error==1)
  71. echo("ALLREADY IN DATABASE");
  72. }
  73.  
  74. mysql_close($con);
  75.  
  76. ?>
Add Comment
Please, Sign In to add comment