public function addNewCategoryAction() { if ($this->request->isPost()) { Category::AddCategory($this->request->getPost('name'), $this->request->getPost('idparent')); header('Location: index'); } }
<?php require_once '../common/config/config.inc.php'; require_once SOURCE_ROOT . 'components/class.validation.inc.php'; require_once SOURCE_ROOT . 'classes/class.category.php'; // CREATING THE CLASS OBJECTS FOR INCLUDING CLASS FILES $objCategory = new Category(); //add example details if Example ID is blank if ($_POST['frmAddEdit'] != '') { if ($objCategory->AddCategory($_POST)) { header($_SESSION['sessCategoryRedirectURL']); exit; } else { if ($_POST['frmCategoryID'] != '') { header('location:category_frm_uil.php?CategoryID=' . $_POST['frmCategoryID']); } else { header('location:category_frm_uil.php'); } exit; } } //take action on selected check box if ($_POST['frmChangeAction'] != '' || $_SESSION['sessUpdateList'] != '') { if ($_POST['frmChangeAction'] == 'Delete' || $_POST['frmChangeAction'] == 'Active' || $_POST['frmChangeAction'] == 'Inactive') { $_SESSION['sessUpdateList'] = $_POST; header('Location:category_confirm_action.php'); exit; } //$_SESSION['sessUpdateList'] = $_POST; $objCategory->validAction($_SESSION['sessUpdateList']); } else {
<?php include '../Class/categories.php'; include "../../connection.php"; $CAtegoryid = $_POST['categoryid']; $CAtegoryname = $_POST['categoryname']; $sql = "select * from tblcategories where CategoryName='{$CAtegoryname}'"; $result = mysqli_query($conn, $sql); if (empty($CAtegoryname)) { echo 'Room Name is required'; } else { if (mysqli_num_rows($result) > 0) { echo 'Category name is already exist'; } else { $Category = new Category($CAtegoryid, $CAtegoryname); if ($Category->AddCategory()) { echo "true"; } else { echo 'error'; } } }