Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 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.                        <table cellpadding=\"0\" cellspacing=\"0\">
  15.                                                        <tr>
  16.                        <form action=\"index.php?page=user_edit\" method=\"post\">
  17.                                <b>Email Account:</b><br/> <input type=\"text\" name=\"email\" value=\"".$s['email']."\" /><br/><br/>
  18.                                <div style=\"margin-left:80px;\">
  19.                                        <b>Current Password:</b><br/> <input type=\"password\" name=\"current_pass\" /> ".$blank." <br/><br/>
  20.                                        <b>New Password:</b><br/> <input type=\"password\" name=\"new_pass\" /> ".$blank." <br/><br/>
  21.                                        <b>Confirm New Password:</b><br/> <input type=\"password\" name=\"c_new_pass\" /> ".$blank." <br/><br/>
  22.                                </div>
  23.                                <input type=\"submit\" value=\"Update Profile\" />
  24.                        </form>
  25.                ";
  26.         }
  27.         elseif($_POST){
  28.                 $username=$_SESSION['username'];
  29.                 $email=$_POST['email'];
  30.                 $current_pass=md5($_POST['current_pass']);
  31.                 $new_pass=md5($_POST['new_pass']);
  32.                 $c_new_pass=md5($_POST['c_new_pass']);
  33.                 $count=mysql_num_rows($select);
  34.                 if($count==0){
  35.                         echo"We were unable to find an account under this username.";
  36.                 }
  37.                 elseif(!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email)){
  38.                         echo"Please enter a valid email address.";
  39.                 }
  40.                 elseif($email==NULL){
  41.                         echo"You cannot leave your email blank.";
  42.                 }
  43.                 else
  44.                 {
  45.                         if(strlen($current_pass)){
  46.                 if($current_pass != $s['password']){
  47.                     echo"Your current password was not correct.";
  48.                 }
  49.                                 elseif($new_pass != $c_new_pass){
  50.                                         echo"Your new passwords did not match.";
  51.                                 }
  52.                                 else
  53.                                 {
  54.                                         mysql_query("UPDATE login_users SET email='".$email."', password='".$new_pass."' WHERE username='".$username."'");
  55.                                                 echo "Updated! Click here to go <a href=\"index.php\">back</a>";
  56.                                 }
  57.                         }
  58.                         else
  59.                         {
  60.                                 mysql_query("UPDATE login_users SET email='".$email."' WHERE username='".$username."'");
  61.                         }
  62.                 }
  63.         }
  64. ?>
  65.                                                         </tr>
  66.                         </table>
  67.                         <br>
  68.                       </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement