<?php
/*============= call when edit user password ================*/
if(isset($_SESSION['sys_id'])){ 
	$usr_id= $_SESSION['sys_id'];
	$usr = mysql_query("select * from v_user WHERE sysuserid = $usr_id");
}
if (isset($_POST['type']) && isset($_POST['btnsave'])) {
	for ($i = 0; $i < count($_POST['type']); $i++) {	
		/*------------ get the warehouse ID -----------------*/
		$usr_id = mysql_real_escape_string(stripslashes($_POST['usr_id'][$i])); 
		$old_password = mysql_real_escape_string(stripslashes($_POST['old_password'][$i])); 
		$new_password = mysql_real_escape_string(stripslashes(trim($_POST['new_password'][$i])));
		$confirm_pass = mysql_real_escape_string(stripslashes(trim($_POST['confirm_pass'][$i])));
		$passmd5 = md5($new_password);
		/*--------------------------------------------------------------*/
		
		if ($_POST['old_password'][$i] != "" && $_POST['new_password'][$i] != ""&& $_POST['confirm_pass'][$i] != "" ) {	
			//echo $_POST['type'][$i]."<br>";
			switch ($_POST['type'][$i]) {	

				case "edited":		
					sql_execute("UPDATE sys_user SET password = '$passmd5' WHERE sysuserid = $usr_id ");
				break;
			}
		}	
	}
	header("Location: ?d=".$_GET['d']."&start=".$_GET['start']);
}

//$result = LoadUser($whereclause, $limitclause);
