daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Start session
  2.     session_start();
  3.    
  4.     if(isset($_SESSION['s_logged_n']) && $_SESSION['s_logged_n'] == 'true'){
  5.    // Define $username
  6.    $username = $_SESSION['s_username'];
  7.     // Check if form button update has been pressed
  8.     if(isset($_POST['update'])){
  9.     // Get the id
  10.     $id = $_GET['id'];
  11.     // Include config file
  12.     include "config.php";
  13.     // Add slashes and trim password
  14.     $password=$_GET["password"];
  15.     $password_confirm=$_GET["password_confirm"];
  16.     $password = addslashes(trim($password));
  17.     $password_confirm = addslashes(trim($password_confirm));
  18.     // Check if passwords match each other
  19.     if ($password == $password_confirm){
  20.     // If they do then do md5 hash on it
  21.     $password = md5($password);
  22.     // Query users table
  23.     $query = "UPDATE users SET password = '$password' WHERE userid = '$id' AND username = '$username' LIMIT 1";
  24.     $result = mysql_query($query);
  25.     // If it was successfull change of pass then output it
  26.     if($result){
  27.     echo "You have successfully edited your password";
  28.     } else {
  29.     // Else output error
  30.     echo "There was an error editing your password";
  31.     }
  32.     } else {
  33.     // If passwords don't match each other say so
  34.     echo "Your passwords don't match each other";
  35.     }
  36.     }
  37.     } else {
  38.     // If someone just try to open file then stop them
  39.     echo "You must be logged in to access this area";
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top