<?php include 'categoryclass.php'; if (isset($_POST['Add'])) { if (!empty(trim($_POST['catname']))) { $name = $_POST['catname']; $categ = new category(); $categ->insert($name); } } include 'header1.php'; ?> <form action="addcategory.php" method="post"> <div id="inside"> <div class="container"> <div class="row"> <table class="table table-bordered table-hover table-striped table-responsive"> <tr><th colspan="2"><h2>Add new category</h2></th></tr> <tr> <th>category name</th> <td><input type="text" name="catname"/></td> </tr> <tr> <td></td> <td id="submit"><input type="submit" name="Add" value="Add" ></td> </tr> </table> </form> <br/>
if (empty(trim($_GET['name']))) { $errors[] = "the name is empty"; $_SESSION['errors'] = $errors; } if ($category->category_is_exist($_GET['name'])) { $errors[] = "the category is already exist"; $_SESSION['errors'] = $errors; } if (empty(trim($_GET['desc']))) { $errors[] = "the desc is empty"; $_SESSION['errors'] = $errors; } if (empty($errors)) { $category->category_name = $_GET['name']; $category->category_desc = $_GET['desc']; $category->insert(); } $data = $category->getallcategory(); $response1 = []; $response1[] = $data; $response1[] = $errors; $jsondata = json_encode($response1); echo $jsondata; // $category = new category(); // $category->category_name = $_GET['name']; // $category->category_desc = $_GET['desc']; // $category->insert(); // $data = $category->getallcategory(); // $jsondata = json_encode($data); // echo $jsondata; } else {
<button type="reset" name="cancel" class="red"><?php echo $language['cancel']; ?> </button> </div> </form> <?php } else { if (isset($_REQUEST['published'])) { $_REQUEST['published'] = true; } else { $_REQUEST['published'] = false; } $object_category = new category(); $object_category->setContent($_REQUEST['title_1'], $_REQUEST['content_1'], $_REQUEST['title_2'], $_REQUEST['content_2'], $_REQUEST['title_3'], $_REQUEST['content_3'], $_REQUEST['title_4'], $_REQUEST['content_4'], $_REQUEST['title_5'], $_REQUEST['content_5'], $_REQUEST['title_6'], $_REQUEST['content_6'], $_REQUEST['code']); $object_category->setUserId($account["name"]); $object_category->setDate(); $object_category->setDateUpdate(); $object_category->setPublished($_REQUEST['published']); $object_category->setCategoryType($_REQUEST['section']); if ($object_category->insert()) { print 'sucess'; } else { print 'failure'; } } ?> </div>