<?php
ob_start();
session_start();
require_once("../conn/conn.php");
include('../utility/chksession.php');
date_default_timezone_set("Asia/Bangkok");


$mc_id=$_POST['mc_id'];
$mc_name=$_POST['mc_name'];

echo $mc_id;

//exit;


if($mc_id == "" || $mc_name == ""){
    ?>
        <script language="JavaScript" type="text/javascript">
			<!--
			alert("กรุณากรอกข้อมูลให้ครบถ้วน !!! ");
			location.href='../admin/add_mechanical.php';
			//-->
		</script>
    <?php 
}else{
    
    $sql = "INSERT INTO `ma_mechanical` (`mc_id`, `mc_name`) VALUES ('$mc_id', '$mc_name')";
	$query = mysqli_query($con,$sql);
        if($query){
            ?>
                <script language="JavaScript" type="text/javascript">
                    <!--
                    alert("บันทึกข้อมูลเรียบร้อย");
                    location.href='../admin/add_mechanical.php';
                    //-->
                </script>
            <?php
        }else{
            
            echo "Error: " . $sql . "<br>" . mysqli_error($con);

        }
        mysqli_close($con);
}




?>