Advertisement
Guest User

Untitled

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