Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Start session
- session_start();
- if(isset($_SESSION['s_logged_n']) && $_SESSION['s_logged_n'] == 'true'){
- // Define $username
- $username = $_SESSION['s_username'];
- // Check if form button update has been pressed
- if(isset($_POST['update'])){
- // Get the id
- $id = $_GET['id'];
- // Include config file
- include "config.php";
- // Add slashes and trim password
- $password=$_GET["password"];
- $password_confirm=$_GET["password_confirm"];
- $password = addslashes(trim($password));
- $password_confirm = addslashes(trim($password_confirm));
- // Check if passwords match each other
- if ($password == $password_confirm){
- // If they do then do md5 hash on it
- $password = md5($password);
- // Query users table
- $query = "UPDATE users SET password = '$password' WHERE userid = '$id' AND username = '$username' LIMIT 1";
- $result = mysql_query($query);
- // If it was successfull change of pass then output it
- if($result){
- echo "You have successfully edited your password";
- } else {
- // Else output error
- echo "There was an error editing your password";
- }
- } else {
- // If passwords don't match each other say so
- echo "Your passwords don't match each other";
- }
- }
- } else {
- // If someone just try to open file then stop them
- echo "You must be logged in to access this area";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement