reset.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. require_once('php/db_utils.php');
  3. if(isset($_GET['salt'])) { // Parameter received
  4. $salt = $_GET['salt']; // Get parameter
  5. $conn = db_connect(); // Connect to the database
  6. // Check if the user already exists
  7. if(!($result = mysqli_query($conn, "SELECT * FROM user WHERE salt = '$salt'"))) {
  8. $verification = 'false'; // Wrong query
  9. }
  10. else { // Query successful
  11. if(mysqli_num_rows($result) != 1) { // User doesn't exist, or duplicated
  12. $verification = 'false';
  13. }
  14. else { // User returned successfully ?>
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <meta charset="UTF-8">
  19. <meta name="viewport" content="width=device-width, initial-scale=1">
  20. <!-- favicon -->
  21. <link rel="icon" href="icon/favicon.ico"/>
  22. <title>Online Ethics Canvas|Reset Your Password</title>
  23. <!-- Bootstrap -->
  24. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  25. <!-- Google font -->
  26. <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
  27. <link rel="stylesheet" type="text/css" href="css/landing.css">
  28. </head>
  29. <body>
  30. <div class="container-fluid">
  31. <div class="row">
  32. <div class=" new-password col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3">
  33. <div class="form-new-password-feedback "></div>
  34. <form class="new-password-form" method="post" action="php/changePassword.php">
  35. <h1>Get A New Password</h1>
  36. <p>
  37. <label for="new-password">New Password</label>
  38. </p>
  39. <p>
  40. <input type="password" name="new-password" id="new-password" required/>
  41. </p>
  42. <div class="form-message" id="new-password-message1"></div>
  43. <p>
  44. <label for="new-password-conf">Confirm Password</label>
  45. </p>
  46. <p>
  47. <input type="password" name="new-password-conf" id="new-password-conf" required/>
  48. </p>
  49. <div class="form-message" id="new-password-message2"></div>
  50. <input type="hidden" name="salt" id="salt" value="<?php print "$salt" ?>"/>
  51. <p>
  52. <button class="new-pass-btn" name="password-change" type="submit">Done!</button>
  53. </p>
  54. </form>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- end of outer container-fluid -->
  59. <!-- jQuery -->
  60. <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
  61. <!-- The app javascript -->
  62. <script src="js/reset.js" charset="utf-8"></script>
  63. </body>
  64. </html>
  65. <?php }
  66. }
  67. mysqli_free_result($result);
  68. db_close($conn); // Close the database
  69. }
  70. else { // Salt not been sent as parameter
  71. $verification = 'false';
  72. }
  73. ?>