Advertisement
Guest User

Untitled

a guest
May 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2. require_once('base.php');
  3.  
  4. if(empty($_POST['oldpassword'])) { ?>
  5. <form method="post" action="<?php echo $PHP_SELF; ?>" name="changepw" id="form">
  6.  
  7. <strong><label for="password">Old Password:</label></strong>
  8. <input type="password" name="oldpassword" id="oldpwd" size="47" length="12" />
  9. <br>
  10. <strong><label for="password">New Password:</label></strong>
  11. <input type="password" name="newpassword" id="newpwd" size="47" length="12" />
  12. <br>
  13. <input type="submit" value="Submit" id="submit" name="pwchangesubmit" />
  14.  
  15. <?php } elseif($_POST['oldpassword'] && $_POST['newpassword']) {
  16.  
  17. $oldpass = $_POST['oldpassword'];
  18. $newpass = $_POST['newpassword'];
  19. $username = $_SESSION['username'];
  20.  
  21. if (!ctype_alnum($oldpass)) {
  22. die("Please use Alphanumeric characters only.");
  23. };
  24.  
  25. if (!ctype_alnum($newpass)) {
  26. die("Please use Alphanumeric characters only.");
  27. };
  28.  
  29. $checkoldpass = mssql_query("SELECT * FROM dbo.Login WHERE PWD = 'CONVERT(varbinary,".$oldpass).")' ");
  30.  
  31. if(mssql_num_rows($checkoldpass) != 1)
  32. {
  33. echo "<h1>Error</h1>";
  34. echo mssql_num_rows($checkoldpass);
  35. echo "<p>Sorry, you entered the wrong old password. Please go back and try again.</p>";
  36. }
  37. elseif(mssql_num_rows($checkoldpass) == 1)
  38. {
  39. $changepass = mssql_query("UPDATE dbo.Login SET PWD = 'CONVERT(varbinary,".passconvert($newpass).")'");
  40. if($registerquery)
  41. {
  42. echo "<h1>Success</h1>";
  43. echo "<p>Your password has been sucessfully changed.</p>";
  44. }
  45. else
  46. {
  47. echo "<h1>Error</h1>";
  48. echo "<p>Sorry, your password change failed. Please go back and try again.</p>";
  49. }
  50. }
  51. }
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement