<?php session_start();
include("./../config/config.php");  
include("./backend/validated_admin.php");  
$sql_blog_id = "SELECT * FROM blog_category_add ";
$myquery_blog_id=$conn->query($sql_blog_id);
$mydara_blog_id =$myquery_blog_id->fetchAll();
$row_found_blog_id = $myquery_blog_id->rowCount();
if($row_found_blog_id>0){
    foreach($mydara_blog_id as $row_form){
        $idblog= $row_form['addblog'];    
      $ids = $row_form['idcodes'];
    }
   }
?>
<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Blog - iCouponWorld | Coupons | Discounts| Promo Codes<</title>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <link id="favicon" rel="icon" type="image/x-icon" href="../images/web-images/home/favicon.png">
      <meta name="robots" content="index, follow" />
      <meta name="author" content="Design Collection">
      <meta name="description" content="With Edit Delete Master you can edit and delete pages">
      <link rel="canonical" href="create-post.php"/>
      <meta name="keywords" content="Edit, Delete,Edit Delete Master">
      <!-- Viewport configuration, scaling options -->
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
      <!-- Bootstrap CSS -->
      <link href="../css/icouponworld.css" rel="stylesheet">
      <!-- CSS Stylesheet -->
      <link href="../css/dashboard.css" rel="stylesheet">
      <!-- Font Awesome icon -->
      <link href="../fontawesome/css/fontawesome.css" rel="stylesheet" />
      <!-- Roboto font  -->
      <link rel="preconnect" href="https://fonts.googleapis.com">
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&display=swap" rel="stylesheet">
      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
      <!--unique id begin -->
      <div id="s_mm">
         <!--scroll-top Begin-->
         <div id="scroll-top">
            <!--sidebarwrapper Begin-->
            <div id="sidebarwrapper">
               <!--Sidebarmenu Begin-->
               <?php include("./includefiles/sidebar.php"); ?>
               <!--Sidebarmenu End-->
               <!--content-wrapper Begin-->
               <div id="content-wrapper" class="d-flex flex-column dashboard-navbar">
                  <div id="maincontent">
                     <!-- Navbar Topbar Begin-->
                     <?php include("./includefiles/header.php"); ?>
                     <!-- Navbar Topbar End-->
                     <!-- Container Begin-->
                     <div class="container-fluid px-4">
                        <div class="d-sm-flex align-items-center justify-content-between mb-4">
                           <h3>
                              Create Post  Webpages
                           </h3>
                        </div>
                        <?php include("./includefiles/coupon_count.php"); ?>
                        <div class="row">
                           <div class="col-md-12">
                              <div class="mb-4">
                                 <!--Alert Message Begin-->
                                 <div class="alert alert-primary fs-14 mt-2" role="alert">
                                    <strong>Important message:</strong>  You can create your Post page very easily. 
                                 </div>
                                 <!--Alert Message End-->
                              </div>
                              <?php 
                                     if($_SESSION['save-blog'] !=""){?>
                                        <div class="alert alert-success" role="alert">
                                       Your Blog Create successfully!
                                     </div>
                                     <?php
                                     }
                                     unset($_SESSION['save-blog']);
                                  ?>
                           </div>
                           <form action="./backend/add_blog_category.php" method="post" enctype="multipart/form-data">
                              <div class="row">
                                 <!--Google Analytics Code Past Here Begin-->
                                 <div class="col-md-12">
                                    <div class="card border-0  shadow mb-4">
                                       <div class="card-header bg-white border-bottom py-3">
                                          <h6 class="m-0 fw-bold">Create Post Web Page</h6>
                                       </div>
                                       <div class="card-body">
                                          <div class="row">
                                             <div class="col-md-12">
                                                <div class="mb-3">
                                                   <label for="metatitle" class="form-label">Meta Title <span class="text-danger">*</span><small >(should not be more than 70 character)</small></label>
                                                   <input type="text" name="<?=SESS_MASTER?>metatitle" class="form-control" maxlength="60" id="metatitle">
                                                </div>
                                             </div>
                                             <div class="col-md-12">
                                                <div class="mb-3">
                                                   <label for="metadescription" class="form-label">Meta Description <span class="text-danger">*</span><small >(should not be more than 160 character)</small></label>
                                                   <input type="text" name="<?=SESS_MASTER?>metadesc" class="form-control" maxlength="160" id="metatitle">
                                                   <input type="hidden" name="<?=SESS_MASTER?>idcodes" value="<?php echo rand()?>" class="form-control" maxlength="160" >
                                                </div>
                                             </div>
                                             <div class="col-md-12">
                                                <div class="mb-4">
                                                   <label for="metakeyword" class="form-label">Meta Keyword <span class="text-danger">*</span><small >(should not be more than 8 to 10 word)</small></label>
                                                   <input type="text" name="<?=SESS_MASTER?>metakey" class="form-control" maxlength="160" id="metakeyword">
                                                </div>
                                             </div>
                                             <div class="col-md-12">
                                                <div class="mb-4">
                                                   <label for="blogtitle" class="form-label">Blog Title</label>
                                                   <input type="text" name="<?=SESS_MASTER?>blogtitle" class="form-control" maxlength="160" id="blogtitle">
                                                </div>
                                             </div>
                                             <div class="col-md-12">
                                                <div class="mb-4">
                                                   <label for="metakeyword" class="form-label">Blog Image </label>
                                                   <input type="file" name="<?=SESS_MASTER?>file_up" class="form-control" maxlength="160" id="metakeyword">
                                                </div>
                                             </div>
                                             <div class="row justify-content-center align-items-center">
                                                <div class="col-md-8">
                                                   <div class="mb-4">
                                                      <label for="Category" class="form-label">Category: </label>
                                                      <div class="form-group">
                                                         <select class="form-select" name="<?=SESS_MASTER?>category" required>
                                                            <option>Select Category</option>
                                                            <?php 
                                                               $sql_create_form = "SELECT * FROM  category_add";
                                                               $myquery_create_form=$conn->query($sql_create_form);
                                                               $mydara_create_form =$myquery_create_form->fetchAll();
                                                               $row_found_create_form = $myquery_create_form->rowCount();
                                                               if($row_found_create_form>0){
                                                                   foreach($mydara_create_form as $row_form){
             
                                                                    $category_name = $row_form['category_name'];

                                                            ?>
                                                            <option value="<?=$category_name?>"><?=$category_name?></option>
                                                           <?php } } ?>
                                                         </select>
                                                      </div>
                                                   </div>
                                                </div>
                                                <div class="col-md-4">
                                                   <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
                                                   <i class="fas fa-plus pe-1"></i> Add Category
                                                   </button>
                                                
                                                
                                                </div>
                                             </div>
                                             <div class="col-md-12">
                                                <div class="mb-3">
                                                   <label for="content" class="form-label">Content: </label>
                                                   <textarea name="editor1" required ></textarea>
                                                </div>
                                             </div>
                                          </div>
                                       </div>

                                          
                                    </div>
                                 </div>
                                 <!---Google Analytics Code Past Here End-->
                                 <div class="col-lg-12 col-sm-12 mx-auto">
                                    <button type="submit" class="btn btn-primary mt-2 mb-5">Create</button>
                                    <a href="../blog-details.php?id=<?=$idblog?>" target="blank"  class="btn btn-primary mt-2 mb-5">Preview</a>
                                 </div>
                                 
                              </div>
                           </form>
                        </div>
                        <!-- Update Modal Begin -->
                                                 
                        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                      <div class="modal-dialog">
                                                      <form action="./backend/add_category.php" method="post">
                                                         <div class="modal-content">
                                                         
                                                           <div class="modal-header">
                                                               <h5 class="modal-title" id="exampleModalLabel">Add Category</h5>
                                                               <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                                            </div>
                                                            <div class="modal-body">
                                                               <div class="mb-4">
                                                                  <label for="Category" class="form-label">Category: </label>
                                                                  <div class="form-group">
                                                                     <input type="text" name="<?=SESS_MASTER?>add_category"  class="form-control" maxlength="50">
                                                                  </div>
                                                               </div>
                                                            </div>
                                                            <div class="modal-footer bg-white">
                                                               <button type="submit" id="submit" class="btn btn-primary">Yes</button>
                                                               <a class="btn btn-secondary" data-bs-dismiss="modal">No</a>
                                                            </div>
                                                          
                                                         </div>
                                                        </form>
                                                      </div>
                                                   </div>
                                                   
                                                   <!-- Update Modal End -->
                     </div>
                     <!-- Container End-->
                  </div>
                  <!--Copyright Begin-->
                  <div class="p-4 border bg-white">
                     <div class="container">
                        <div class="row align-items-center">
                           <div class="col-lg-12 col-sm-12">
                              <p class="small text-center p-0 m-0">© 2022. All Rights Reserved. Proudly Designed By icoupon world Team. </p>
                           </div>
                        </div>
                     </div>
                  </div>
                  <!--Copyright End-->
               </div>
               <!--content-wrapper End-->
            </div>
            <!--sidebarwrapper End-->
            <!--Scroll to top Begin-->
            <a class="scroll-to-top rounded" href="#scroll-top">
            <i class="fas fa-angle-up"></i>
            </a>
            <!--Scroll to top End-->
            <!-- Jquery Script Begin-->
            <script src="../js/jquery-3.4.1.min.js"></script>
             <!-- Jquery Script End-->
            <!-- Bootstrap Script Begin-->
            <script src="../js/bootstrap.bundle.min.js"></script>
            <!-- Bootstrap Script End-->
            <!--dashboard-icouponworld Script Begin-->
            <script src="../js/dashboard-icouponworld.js"></script>
           
            <!--dashboard-icouponworld Script End-->
               <!--ckeditor.js Script Begin-->
            <script src="https://cdn.ckeditor.com/4.14.1/standard/ckeditor.js"></script>
              <!--ckeditor.js Script End-->
              <!--editor1 Script Begin-->
            <script>
               CKEDITOR.replace( 'editor1' );
            </script>
            <!--editor1 Script End-->
            <!--gtag Script Begin-->
            <script>
               window.dataLayer = window.dataLayer || [];
               function gtag(){dataLayer.push(arguments);}
               gtag('js', new Date());
               
               gtag('config', 'UA-151767913-1');
            </script>
           
            <!--gtag Script End-->
         </div>
         <!--scroll-top End-->
      </div>
      <!--unique id End -->
   </body>
</html>