Question: how can i update a current users md5 password, this is what i have currently... db.php ------------------------- updatepassword.php Old Password: New Password: ------------------------------------------------- pwchange.php

how can i update a current users md5 password, this is what i have currently...

db.php

//sql connection variables

$db_host = "localhost";

$db_username = "demo";

$db_password = ""; // Database password

$db_data = "demo"; // Database here

$db= mysqli_connect ($db_host, $db_username, $db_password, $db_data)

or die ('I cannot connect to the database. ');

?>

-------------------------

updatepassword.php

Old Password:

New Password:

-------------------------------------------------

pwchange.php

require('db.php');

session_start();

if($_REQUEST['update'] == 'edit')

{

$id = safe($_POST['id']);

$password = safe($_POST['password']);

$newpassword = $_POST['newpassword'];

if(md5($password) == $_SESSION['username']['password'])

{

if(empty($newpassword))

{

$password = $_SESSION['username']['password'];

}

else

{

$password = hash('md5', $newpassword);

}

$query = $db->query("UPDATE users SET password = '".$password."' WHERE Id = '".$id."' ");

if($db ,$query)

{

$msg = "password changed successfully";

}

}

header("Location: members.php"); // reroutes to members page

}

?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!