<?php
include('includes/config.php');
	
	$first_name = $_POST['firstname'];
	$last_name = $_POST['lastname'];
	$middle_initial = $_POST['middle_initial'];
	$gender = $_POST['gender'];
	$company = $_POST['company'];
	$street = $_POST['street'];
	$city = $_POST['city'];
	$province = $_POST['province'];
	$contact = $_POST['contact'];
	$guards = $_POST['guards'];
	//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("INSERT INTO clients (`first_name`, 
				`last_name`, `middle_initial`, 
				`gender`, `company`, `street`, 
				`city`, `province`, `contact`, 
				`guards`) 
				VALUES('$first_name', '$last_name', 
				'$middle_initial', '$gender', 
				'$company', '$street', '$city', 
				'$province', '$contact', '".implode('<br />', $out) ."')
				") or die(mysql_error());
				
	echo "success";

//for history log
mysql_query("INSERT INTO history (`data`,`actions`,`date`,`user`)
			VALUES('$first_name $last_name', 'added client', '$pc_date $pc_time', '$user')")or die(mysql_error());	

?>