Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago