<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<link type="text/css" href="css/styles.css" rel="stylesheet">
<title>Viva | QGoal.com</title>
</head>
<body>
<?
include "include/connect.php";
$birthday = $_POST['bYear']."-".$_POST['bMonth']."-".$_POST['bDate'];
$sql_cust = "select * from tbl_info_cust_det where f_cust_id = '$_POST[cust_id]'";
$result_sql_cust= mssql_query($sql_cust);
$row_cust=mssql_fetch_array($result_sql_cust);
$sql_list = "update tbl_info_contact_list SET f_firstname = '$_POST[c_name]', f_lastname = '$_POST[c_surname]' where f_firstname = '$row_cust[f_name]' and f_lastname = '$row_cust[f_surname]'";
mssql_query($sql_list);
//echo $sql_list;
$sql_main = "update tbl_info_contact_main SET f_firstname = '$_POST[c_name]', f_lastname = '$_POST[c_surname]' where f_firstname = '$row_cust[f_name]' and f_lastname = '$row_cust[f_surname]'";
mssql_query($sql_main);
//*** ตรวจสอบข้อมูลซ้ำ
$sql_tel="SELECT * FROM tbl_info_cust_det where (f_ani2='".$f_ani1."')";
$query=mssql_query($sql_tel);
if(mssql_num_rows($query)!= 0)
{
echo "<script type='text/javascript'>alert('เบอร์โทรนี้มีอยู่แล้วกรุณาตรวจสอบ');window.history.go(-1);</script>" ;
exit();
}
// จบตรวจสอบข้อมูลซ้ำ
$sql = "update tbl_info_cust_det SET f_ani1 = '$_POST[tel1]', f_ani2 = '$_POST[tel2]', f_name = '$_POST[c_name]',
f_surname = '$_POST[c_surname]', f_birthday = '$birthday', f_age = '$_POST[age]', f_sex = '$_POST[sex]',
f_status = '$_POST[m_status]', f_weight = '$_POST[weight]', f_hight = '$_POST[hight]', f_occupation = '$_POST[job]',
f_addr1_license = '$_POST[home_no1]', f_addr1_salutation = '$_POST[salutation_address1]',
f_addr1_name = '$_POST[clientVillegeName1]', f_addr1_no = '$_POST[clientVillegeNo1]', f_addr1_soi = '$_POST[clientSoi1]',
f_addr1_road = '$_POST[clientRoad1]', f_addr1_subdistrict = '$_POST[clientSubdistrict1]', f_addr1_district = '$_POST[clientDistrict1]',
f_addr1_province = '$_POST[clientProvince1]', f_addr1_zipcode = '$_POST[clientZipcode1]', f_addr2_license = '$_POST[home_no2]',
f_addr2_salutation = '$_POST[salutation_address2]' , f_addr2_name = '$_POST[clientVillegeName2]', f_addr2_no = '$_POST[clientVillegeNo2]',
f_addr2_soi = '$_POST[clientSoi2]', f_addr2_road = '$_POST[clientRoad2]' , f_addr2_subdistrict = '$_POST[clientSubdistrict2]',
f_addr2_district = '$_POST[clientDistrict2]', f_addr2_province = '$_POST[clientProvince2]',
f_addr2_zipcode = '$_POST[clientZipcode2]' , f_cust_detail = '$_POST[cust_detail]', f_cust_remark = '$_POST[remark]'
where f_cust_id = '$_POST[cust_id]'";
mssql_query($sql);
?>
<script type="text/javascript">
alert("บันทึกข้อมูลเรียบร้อย")
window.location = "edit_customer.php?cust_id=<? echo $_POST[cust_id];?>"
</script>
</body>