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
-------------------------------------------------
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started