<?php
// Include confi.php
include_once('../confi.php');
//$apikey = "123456789";
//if ($_GET['apikey'] == $apikey) {
if($_SERVER['REQUEST_METHOD'] == "POST"){
// Get data
$category_name = isset($_POST['cat_name']) ? mysql_real_escape_string($_POST['cat_name']) : "";
$category_description = isset($_POST['cat_description']) ? mysql_real_escape_string($_POST['cat_description']) : "";
// Insert data into data base
$sql = "INSERT INTO `category` (`cat_id`,`cat_name`,`cat_description`) VALUES (NULL,'$category_name','$category_description');";
$qur = mysql_query($sql);
$result =array();
if($qur){
$result[] = array("msg" => "Done adding category!","Category Name" => $category_name,"Category Description" => $category_description);
$json = array("status" => 1, "info" => $result);
}else{
$json = array("status" => 0, "msg" => "Error adding category!");
}
}else{
$json = array("status" => 0, "msg" => "Request method not accepted");
}
@mysql_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
//}
//else {
// echo "Access Denied";
//}
// Include confi.php
include_once('../confi.php');
//$apikey = "123456789";
//if ($_GET['apikey'] == $apikey) {
if($_SERVER['REQUEST_METHOD'] == "POST"){
// Get data
$category_name = isset($_POST['cat_name']) ? mysql_real_escape_string($_POST['cat_name']) : "";
$category_description = isset($_POST['cat_description']) ? mysql_real_escape_string($_POST['cat_description']) : "";
// Insert data into data base
$sql = "INSERT INTO `category` (`cat_id`,`cat_name`,`cat_description`) VALUES (NULL,'$category_name','$category_description');";
$qur = mysql_query($sql);
$result =array();
if($qur){
$result[] = array("msg" => "Done adding category!","Category Name" => $category_name,"Category Description" => $category_description);
$json = array("status" => 1, "info" => $result);
}else{
$json = array("status" => 0, "msg" => "Error adding category!");
}
}else{
$json = array("status" => 0, "msg" => "Request method not accepted");
}
@mysql_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
//}
//else {
// echo "Access Denied";
//}
No comments:
Post a Comment