%PDF- %PDF-
Direktori : /home/riacommer/domains/gasworld.com.my/private_html/admin/api/ |
Current File : /home/riacommer/domains/gasworld.com.my/private_html/admin/api/product_cat.php |
<?php //error_reporting(-1); //report all error! include_once("security.php"); include_once("db.php"); //[product_category] //for delete only if(isset($_GET["id"])){ if($_GET["id"]!=""){ $id = $_GET["id"]; $sql = "DELETE FROM sa_product_category WHERE id='$id'"; mysql_query($sql); header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("/api", "", dirname($_SERVER['PHP_SELF'])) ."/product_cat.php"); } else { header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("/api", "", dirname($_SERVER['PHP_SELF'])) ."/400.php"); } } else { //for create, update if(isset($_POST["act"])){ $act = trim($_POST["act"]); $product_category = trim($_POST["product_category"]); $desp = trim($_POST["desp"]); if(isset($_POST["publish"])){ $publish = trim($_POST["publish"]); } else { $publish = '0'; } if($act=="create"){ $sql = "INSERT INTO sa_product_category (product_category, desp, publish, created_date) VALUES ('$product_category', '$desp', '$publish', now())"; mysql_query($sql); header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("/api", "", dirname($_SERVER['PHP_SELF'])) ."/product_cat.php"); } else if($act=="update"){ $id = trim($_POST["id"]); $sql = "UPDATE sa_product_category SET product_category='$product_category', desp='$desp', publish='$publish', last_updated=now() WHERE id='$id'"; mysql_query($sql); header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("/api", "", dirname($_SERVER['PHP_SELF'])) ."/product_cat.php"); } } else { header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("/api", "", dirname($_SERVER['PHP_SELF'])) ."/400.php"); } } ?>