<?php
include("../include/session.php");




$userid = mysql_real_escape_string($_GET['user_id']);
$pass = mysql_real_escape_string ($_GET['old_password_text']);
$pass = md5($pass);
$new_pass = mysql_real_escape_string ($_GET['user_password_text']);
$return_page = $_GET['return_page'];
$table_name = "man_users";
$old_password_query = "SELECT  password FROM $table_name WHERE userid = '".$userid."' ";
$old_password_result = execsql($old_password_query);
$saved_old_password = mysql_result($old_password_result, 0, "password");
$old_num = mysql_num_rows($old_password_result);


if ($saved_old_password==$pass) {

$table_name = $_SESSION['db_prefix']."_users";
$reset_query = "UPDATE $table_name SET password = '". md5($new_pass) ."' WHERE userid = '".$userid ."' ";


$reset_result = mySQL_query($reset_query);

$user_name = $_SESSION['username'];

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$table_name = $_SESSION['db_prefix']."_tracking_admin";
$trackingQuery = "INSERT INTO $table_name (entry_date, user_name, action, details_1, details_2, details_3, details_4) VALUES ('".$entry_date."' ,'".$_SESSION['username']."', '4', '".$user_name."' ,'','','' )";
$trackingResult = mySQL_query($trackingQuery);

$m=1;
}
else {
$m=2;
}
?>

<script language="javascript" type="text/javascript">
        window.location="../admin_module/changing_password.php?m=<?php echo $m ?>&return_page=<?php echo "../".$_SESSION['location'] ?>&page=";
</script>

																  