CasperSecurity
<?php
session_start();
include '../../connection/connection.php';
$unit_code = $_REQUEST['unitcode'];
$unit_name= $_REQUEST['unitname'];
$location_id= $_REQUEST['location_id'];
$user_id = '1';
$date = date("Y-m-d");
$is_active = 'yes';
if(!empty($unit_code)){
$db_handle = new DBController();
$check = $db_handle->numRows("SELECT * FROM asset_unit WHERE asset_unit_code = '$unit_code'");
// Retrieve the new id from your form
// Set the MySQL query to run which will update table
if($check >= '1'){
$_SESSION['ERROR_MSG'] = "Asset Unit Already Exist";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:../../../web/home/modules/setup/assetunit/assetunitgrid.php');
}else{
$db_handle = new DBController();
$newInsert = $db_handle->tableinsert("INSERT INTO asset_unit (asset_unit_code,asset_unit_name,location_id,created_on,created_by,is_active)
VALUES ('$unit_code','$unit_name','$location_id','$date','$user_id','$is_active')");
if($newInsert == TRUE){
$_SESSION['ERROR_MSG'] = "Success";
$_SESSION['MSG_ALRT'] = "TRUE";
header('location:../../../web/home/modules/setup/assetunit/assetunitgrid.php');
}else{
$_SESSION['ERROR_MSG'] = "Unsuccess";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:../../../web/home/modules/setup/assetunit/assetunitgrid.php');
}
}
}
?>