Guest User

password script - click here

a guest
Jan 26th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <?php
  2.  
  3. // Password changing script for UberCMS
  4. // Recoded: 6th March 2012.
  5. // Copyright (c) Jonty M
  6.  
  7. if(isset($_POST["SET_NEW_VALUES"])) {
  8. if(isset($_POST["old_password"]) && isset($_POST["password_one"]) && isset($_POST["password_two"]))
  9. {
  10. // Process the $_POST data, encrypt it so it cannot be exploited & prepare it so
  11. // it can be compared with the hash in the database.
  12. $user['old_password'] = $users->UserHash($_POST["old_password"], USER_NAME);
  13. $user['new_pass_one'] = $users->UserHash($_POST["password_one"], USER_NAME);
  14. $user['new_pass_two'] = $users->UserHash($_POST["password_two"], USER_NAME);
  15.  
  16. $p1 = (isset($_POST['p1'])) ? mysql_real_escape_string($_POST['p1']) : '';
  17.  
  18. // Get the users variables from the database
  19. $user['current_password'] = mysql_result(mysql_query("SELECT password FROM users WHERE username = '" . USER_NAME . "'"), 0);
  20.  
  21. if($user['old_password'] == $user['current_password'])
  22. {
  23. if($user['new_pass_one'] == $user['new_pass_two'])
  24. {
  25. mysql_query("UPDATE users SET password = '" . $user['new_pass_two'] . "' WHERE username = '" . USER_NAME . "'");
  26. $_SESSION["UBER_USER_N"] = USER_NAME;
  27. $_SESSION["UBER_USER_H"] = $user['new_pass_two'];
  28.  
  29. define('success', "Password changed successfully.");
  30. }
  31. else
  32. {
  33. define('error', "Your new passwords need to match.");
  34. }
  35. }
  36. else
  37. {
  38. define('error', "Your old password doesn't match with the one we have on our records.");
  39. }
  40. }
  41. else
  42. {
  43. define('error', "Please fill in all the fields.");
  44. }
  45. }
  46.  
  47.  
  48. ?>
  49. <div class="habblet-container" style="float:left; width: 560px;">
  50. <div class="cbb clearfix settings">
  51.  
  52. <h2 class="title">Edit your Zap Account</h2>
  53. <div class="box-content">
  54. <?php
  55. if(defined('success'))
  56. {
  57. ?>
  58. <div class="rounded rounded-green">
  59. <?php echo success; ?><br />
  60. </div>
  61. <div>&nbsp;</div>
  62. <?php
  63. }
  64. else if(defined('error'))
  65. {
  66. ?>
  67. <div class="rounded rounded-error">
  68. <?php echo error; ?><br />
  69. </div>
  70. <div>&nbsp;</div>
  71. <?php
  72. }
  73. ?>
  74.  
  75.  
  76. <form method="post">
  77. Current Password <br /> <input type="password" name="old_password" /> <br /> <br />
  78. New Password <br /> <input type="password" name="password_one" /> <br /><br />
  79. Verify New Password <br / > <input type="password" name="password_two"/> <br />
  80. <br />
  81. <input type="submit" value="Change Password" name="SET_NEW_VALUES" />
  82. </form>
  83. </div>
  84.  
  85.  
  86. </div>
  87. </div>
Advertisement
Add Comment
Please, Sign In to add comment