Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. <?php
  2. check_login('3');
  3. $select=mysql_query("SELECT username,password,email FROM login_users WHERE username='".$username."'");
  4. $s=mysql_fetch_array($select);
  5. if(!$_POST){
  6.  
  7. $blank="<small><i>Leave the Password fields blank to not change them!</i></small>";
  8. echo"
  9. <h2>
  10. <a href=\"#\">Dashboard</a> &raquo; <a href=\"#\" class=\"active\">User Editor</a>
  11. </h2>
  12. <div id=\"main\">
  13. <h3>Please make sure you save your password in a safe location so that you do not forget it!</h3>
  14. <form action=\"index.php?page=user_edit\" method=\"post\">
  15. Email Account:<br/> <input type=\"text\" name=\"email\" value=\"".$s['email']."\" /><br/><br/>
  16. Current Password:<br/> <input type=\"password\" name=\"current_pass\" /> ".$blank." <br/><br/>
  17. New Password:<br/> <input type=\"password\" name=\"new_pass\" /> ".$blank." <br/><br/>
  18. Confirm New Password:<br/> <input type=\"password\" name=\"c_new_pass\" /> ".$blank." <br/><br/>
  19. <input type=\"submit\" value=\"Update Profile\" />
  20. </form>
  21. ";
  22. }
  23. elseif($_POST){
  24. $username=$_SESSION['username'];
  25. $email=$_POST['email'];
  26. $current_pass=md5($_POST['current_pass']);
  27. $new_pass=md5($_POST['new_pass']);
  28. $c_new_pass=md5($_POST['c_new_pass']);
  29. $count=mysql_num_rows($select);
  30. if($count==0){
  31. echo"We were unable to find an account under this username.";
  32. }
  33. elseif(!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email)){
  34. echo"Please enter a valid email address.";
  35. }
  36. elseif($email==NULL){
  37. echo"You cannot leave your email blank.";
  38. }
  39. else
  40. {
  41. if(strlen($current_pass)){
  42. if($new_pass != $c_new_pass){
  43. echo"Your new passwords did not match.";
  44. }
  45. else
  46. {
  47. mysql_query("UPDATE login_users SET email='".$email.", password='".$new_pass."' WHERE username='".$username."'");
  48. }
  49. }
  50. else
  51. {
  52. mysql_query("UPDATE login_users SET email='".$email."' WHERE username='".$username."'");
  53. }
  54. }
  55. }
  56. ?>
  57. </tr>
  58. </table>
  59. <br>
  60. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement