<?php include('site-header.php'); ?>
  <!-- end of LOGO CONTAINER -->
  <!-- - - - - - - - - - - - - -->
  <!-- start of SIDEBAR        -->
  <!-- - - - - - - - - - - - - -->
  <?php include('left-nevigation.php'); ?>
  <!-- - - - - - - - - - - - - -->
  <!-- end of SIDEBAR          -->
  <!-- - - - - - - - - - - - - -->
    <script src="ckeditor/ckeditor.js"></script>
    
  
  <main id="playground">
    <!-- - - - - - - - - - - - - -->
    <!-- start of TOP NAVIGATION -->
    <!-- - - - - - - - - - - - - -->
  <?php include('site-top-header.php'); ?>
    <!-- - - - - - - - - - - - - -->
    <!-- end of TOP NAVIGATION   -->
    <!-- - - - - - - - - - - - - -->
    <!-- PAGE TITLE -->
    <?php
    $tmp = $_FILES['att']['tmp_name'];
    $fn = $_FILES['att']['name'];
    $ext = explode(".",$fn);
    $extt = end($ext);
    $fnn = rand().".$extt";
    extract($_POST);
    
    if(isset($sub))
    {
       $category_name = ucwords(strtolower($_POST['category_name']));
        if($_FILES['att']['name']!=='')
        {   
          $category_name = ucwords(strtolower($_POST['category_name']));
           $sql_insert = "INSERT INTO `tbl_category`(`cate_name`, `category_image`, `cate_desc`) VALUES ('$category_name','$fnn','$cate_desc')";
           if(mysqli_query($link,$sql_insert))
           {
            move_uploaded_file($tmp,"../category-image/$fnn");
            $msg = "<p style='color:green;'>Category Save!!!!</p>";
           }
           else
           {
            $msg = "<p style='color:red;'>Category Not Save Try Again!!!!</p>";
           }
        }
        else
        {
           $category_name = ucwords(strtolower($_POST['category_name']));
           if(mysqli_query($link,"insert into tbl_category(cate_name) values('$category_name')"))
           {
            $msg = "<p style='color:green;'>Category Save!!!!</p>";
           }
        }
    }
    ?>
    <div class="container-fluid textsss">
    <section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Category</h1>
        <p class="lead">Add your Category below</strong>.</p>
      </div>
      <div class="col-md-4">
        <ol class="breadcrumb pull-right no-margin-bottom">
          <li><a href="dashboard.php">Category</a></li>
          <!-- <li class="active">Add Category</li> -->
        </ol>
      </div>
    </section>
    <!-- / PAGE TITLE -->
    <div class="container-fluid">
    <form method="post" enctype="multipart/form-data">
      <div class="row">
         <div class="col-md-12">
         <a href="update-category.php" class="btn btn-primary">Back</a>
        </div>
        <div class="col-md-6">
            <div class="form-group">
              <label class="text-danger"><?=$msg;?></label><br>
              <label for="">Services Category</label>
              <input type="text" class="form-control" name="category_name" value="" placeholder="Enter Your Category Name">
            </div>
            <div class="form-group" align="left">
              <label for="">Image for Category Page (Size : 642 X 432  pixels)</label>
              <img src="">
              <input type="file"  name="att" >
            </div> 
        </div>
      <!--   <div class="col-md-12">
          <div class="form-group">
          <textarea class="form-control" id="ckeditor1" name="cate_desc" style="width:100%"></textarea>
          </div>
        </div> --> 
        <div class="col-md-12">
          <div class="form-group"> 
            <input type="submit" class="btn btn-primary" name="sub" value="SUBMIT">
          </div>
        </div>
      </div>
      </form>
    </div>
  </div>
    <script>
      CKEDITOR.replace(ckeditor1)  
    </script>
    <!-- / container-fluid -->
 <?php include('site-footer.php'); ?>