<script language="JavaScript" src="jscript/md5.min.js"  type="text/javascript"></script>

<?php
include("dbset.php");

$con = mysqli_connect("localhost",$dbu,$dbp);
if (!$con)
  {
  die('Could not connect to database: ' . mysqli_error());
  }
   
mysqli_select_db($con, $dbs);

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

$cx =$_GET['cx'];

$edit_user_name = $_GET['edit_user_name_text'];
$edit_user_password = $_GET['edit_user_password_text'];
$edit_email = $_GET['edit_email_text'];


$table_name = "system_users";
$system_query = "UPDATE $table_name SET password_text = '".$edit_user_password."', password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
$system_result = $con->query($system_query);


$table_name = "system_users";
$companies_query = "SELECT tlh_gab, tlh_ftw, rad_gab, rad_nam, vertex, pecus, admin  FROM $table_name WHERE username = '".$edit_user_name."' ";
$companies_result = $con->query($companies_query);
$row = mysqli_fetch_assoc($companies_result);
$tlh_gab = $row["tlh_gab"];
$tlh_ftw = $row["tlh_ftw"];
$rad_gab = $row["rad_gab"];
$rad_nam = $row["rad_nam"];
$vertex = $row["vertex"];
$pecus = $row["pecus"];
$admin = $row["admin"];


if ($tlh_gab==1) {
		$table_name = "tlh_users";
		$tlh_gab_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$tlh_gab_result = $con->query($tlh_gab_query);
}

if ($tlh_ftw==1) {
		$table_name = "ftw_users";
		$tlh_ftw_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$$tlh_ftw_result = $con->query($$tlh_ftw_query);
}

if ($rad_gab==1) {
		$table_name = "rds_users";
		$rad_gab_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$rad_gab_result = $con->query($rad_gab_query);
}

if ($rad_nam==1) {
		$table_name = "nmb_users";
		$rad_nam_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$rad_nam_result = $con->query($rad_nam_query);
}

if ($vertex==1) {
		$table_name = "ver_users";
		$vertex_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$vertex_result = $con->query($vertex_query);
}

if ($pecus==1) {
		$table_name = "pec_users";
		$pecus_query = "UPDATE $table_name SET password = '".md5($edit_user_password)."', email = '".$edit_email."' WHERE username = '".$edit_user_name."' ";
		$pecus_result = $con->query($pecus_query);
}

//$user_id = $_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']."', '121', '".$username."','','', '' )";
//$trackingResult = mySQL_query($trackingQuery);




?>
<script language="javascript" type="text/javascript">
        window.location="admin_settings.php?s=1&cx=<?php echo $cx ?>";
</script>
<?php
//}
?>



																  