<?php
$unique_key = $_REQUEST['u']; 
session_start();
 date_default_timezone_set('Asia/Kolkata');
if(!isset($_SESSION[$unique_key]) || $_SESSION[$unique_key] !== true){
     header("location: Session_A.php");
    exit;
}
//$img=htmlspecialchars($_SESSION["profile_image"]); 
$fullname=htmlspecialchars($_SESSION["fullname"]);   

$user_image="headicon.jpg"; 

$user_id=htmlspecialchars($_SESSION["user_id"]);
$date_of_entry=date('d-m-Y');
?>

<?php
include('include/header.php');


?>
<body class="vertical dark" oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
  <div class="wrapper">

    <?php
    include('include/sidebar.php')
    ?>
  
      <main role="main" class="main-content">
        <div class="container-fluid">
          <div class="row justify-content-center">
            <div class="col-12">
			<h2 class="h5 page-title">Welcome! <?php echo $fullname; ?></h2>
             
              <div class="card shadow mb-4">
                <div class="card-header">
                  <strong class="card-title">Add</strong>
                </div>
                <div class="card-body">
				 <form method="POST" class="needs-validation" action="Products_API.php" enctype="multipart/form-data">
                  <div class="row">
                    <div class="col-md-6">
					  <div class="form-group mb-3">
                        <label for="simpleinput">Image</label>
                       
					 <input type="file" name="image" class="form-control">
                      </div>
                      <div class="form-group mb-3">
                        <label for="simpleinput">Title</label>
                        <input type="text" name="title" class="form-control" placeholder="Enter the Title" required >
						<input type="hidden" name="u" class="form-control"  value="<?php echo $unique_key; ?>">
                      </div>
                     
                 
                     <div class="form-group mb-3">
                        <label for="simpleinput">Category</label>
                        <input type="text" name="category" class="form-control" placeholder="Enter the Category" required >
						
                      </div>
       
                    </div> <!-- /.col -->
                    <div class="col-md-6">
                   
                       <div class="form-group mb-3">
                        <label for="simpleinput">Short Description</label>
                        <input type="text" name="short_description" class="form-control" placeholder="Enter the Designation" required >
					
                      </div>
					    <div class="form-group mb-3">
                        <label for="simpleinput">Description</label>
						<textarea class="form-control" name="description" ></textarea>
                      
                      </div>
                    </div>
					<div class="col-md-6">
                      <div class="form-group mb-3">
                        <button type="submit" class="btn mb-2 btn-info">Submit</button>
                      </div>
                    
                     <div class="form-group mb-3">
                      
                      </div>
                    </div>
                  </div>
                </div>
				</form>
				
              </div> <!-- / .card -->
             
			   <div class="row">
                <div class="col-md-12 my-4">
              
                  <div class="card shadow">
                    <div class="card-body">
                      <!-- table -->
                      <table class="table table-hover table-borderless border-v">
                        <thead class="thead-dark">
                          <tr>
                            <th>Sl.No</th>
                            <th>Product</th>
                           
                        
						 <th>Category</th>
						 <th>Short Description</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
						  <?php
				
					
							require_once "DBConfig.php";
							$result = mysqli_query($link,"SELECT * FROM product_table");
							if(mysqli_num_rows($result)>0) {
							$i=0;
							while($row = mysqli_fetch_array($result)) {
					?>
					  
                          <tr class="collapsed" >
                            <td><?php echo ++$i; ?></td>
                            <td><?php echo $row["title"]; ?></td>
							
							    <td><?php echo $row["category"]; ?></td>
								  <td><?php echo $row["short_description"]; ?></td>
                           
                         
                             
                            <td><button class="btn btn-sm dropdown-toggle more-horizontal" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <span class="text-muted sr-only">Action</span>
                              </button>
                              <div class="dropdown-menu dropdown-menu-right">
                             
                                <a class="dropdown-item" href="Products_API_D.php?key=<?php echo $row["blog_id"]; ?>&u=<?php echo $unique_key; ?>">Remove</a>
                               
                              </div>
                            </td>
                           
                          </tr>
                      <?php
						}
				}
				else
				{
   					
				}
			?>	
					     
                       
                        
                         
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div> <!-- end section -->
            </div> <!-- .col-12 -->
          </div> <!-- .row -->
        </div> <!-- .container-fluid -->
      
            </div>
          </div>
        </div>
      </main> <!-- main -->
    </div> <!-- .wrapper -->
  <?php 
  include('include/footer.php');
 
include('include/Script.php')
?>
  </body>
</html>