I am currently working on a PHP file, an admin having the privilege of updating the user account's password which has hash, but it is currently not working and updating inside the database. I tried looking for the problem but failed to do so, a little help would be appreciated. Here is my simple code...
edit-accounts-process.php:
<?php
$connect=mysqli_connect('localhost','root','','report_generation');
if(isset($_POST['submit'])) {
$id = $_POST['id'];
$username = $_POST['username'];
$password= $_POST['password'];
$login_name = $_POST['login_name']; //full name of the user
$query = "UPDATE dim_login set username = '$username', password = md5('$password'), login_name = '$login_name', where id = '$id'";
mysqli_query($connect, $query);
header( "Location: user-account.php" ); die;
echo "<script>window.open('user-account.php','_self')</script>";
} ?>
Form:
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Quick Example</h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<?php
$id = $_GET['id'];
$query = "select * from dim_login where id = '$id';";
$run = mysqli_query($connect, $query);
while ($row = mysqli_fetch_array($run)) {
$id = $row[0];
$username = $row[1];
$password = $row[2]);
$login_name = $row[3];
}
?>
<form class="form" action="edit-account-process.php?id=<?php echo $id; ?>" method="post">
<div class="box-body">
<div class="form-group">
<label>Full Name</label>
<input type="text" class="form-control" name="login_name" value="<?php echo $login_name; ?>">
</div>
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" name="username" value="<?php echo $username; ?>">
</div>
<div class="form-group">
<label>New Password</label>
<input type="password" class="form-control" name="password" value="">
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<input type="submit" class="btn btn-primary" value="Submit" name="submit" />
</div>
<input type= "hidden" name = "id" value ="<?php echo $id ?>"/>
</form>
</div>
<!-- /.box -->
</div>
</div>