<?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; 

      if($extt=="jpg"||$extt=="png")

      {   

          $category_name = ucwords(strtolower($_POST['category_name']));

         if(mysqli_query($link,"insert into tbl_category(cate_name,category_image,cate_desc) values('$category_name','$fnn','$about_text')"))

         {

          move_uploaded_file($tmp,"../uploaded/$fnn");

          $msg = "<p style='color:green;'>Category Save!!!!</p>";

         }

         else

         {

          $msg = "<p style='color:red;'>Category Not Save Try Again!!!!</p>";

         }

      }

      else

      {

        $msg ="<p style='color:red;'>Only Png or jpg file uploaded!!!!</p>";

      }

     

    }

    ?>

    <section id="page-title" class="row">

      <div class="col-md-8">

        <h1>Dashboard</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">Dashboard</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="">Product 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 : 277 X 190 pixels)</label>

              <img src="">

              <input type="file" class="form-control" name="att" placeholder="Enter Your Category Image">

            </div>

        </div>

        <div class="col-md-12">

          <div class="form-group">

          <textarea class="form-control" id="ckeditor1" name="about_text" 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>

    <script>

      CKEDITOR.replace(ckeditor1)  

    </script>

    <!-- / container-fluid -->

 <?php include('site-footer.php'); ?>