<?php
	include('includes/config.php');
	
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$middle_initial = $_POST['middle_initial'];
$gender = $_POST['gender'];
$company = $_POST['company'];
$city = $_POST['city'];
$street = $_POST['street'];
$province = $_POST['province'];
$contact = $_POST['contact'];
$guards = $_POST['guards'];
$client = $_POST['id'];
//for history log
	$user = $_POST['user'];
	$pc_date = $_POST['pc_date'];
	$pc_time = $_POST['pc_time'];


$out = array();
foreach ($guards as $value) {
    array_push($out, "$value");		
}		
		mysql_query("UPDATE clients SET first_name ='$first_name', 
					last_name ='$last_name',
					middle_initial ='$middle_initial', 
					gender ='$gender',
					company='$company', 
					city='$city', 
					street='$street', 
					province='$province', 
					contact='$contact', 
					guards='".implode(',', $out) ."' 
					WHERE client_id ='$client'") or die(mysql_error());  
	
echo "success";	
mysql_query("INSERT INTO history (`data`,`actions`,`date`,`user`)
			VALUES('$first_name $last_name', 'modified client', '$pc_date $pc_time', '$user')")or die(mysql_error());	
//for log

?>