  <?php 
     require('top.php');
     $categories='';
     $msg='';
     if (isset($_GET['id']) && $_GET['id']!='') {
      $id=$_POST['id'];
     $res=mysqli_query("select * from categories where id='$id'");
     $check=mysqli_num_rows($res);
     if($check>0){
     $row=mysqli_fetch_assoc($res);
     $categories=$row['categories'];
          } else{
               header('location:categories.php');
        die();
      }
               }
  
     if(isset($_POST['submit'])){
          
          $categories=$_POST['categories'];
          mysqli_query($con,"insert into categories (categories,status) values('$categories','1')");
          
       echo " <script> window.location='categories.php'</script>";
        die();
             }

    ?>
     <div class="content pb-0">
<div class="animated fadeIn">
 <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header"><strong>Categories</strong><small> Form</small></div>
                            <form method="POST" action="">
                            <div class="card-body card-block">
                                <div class="form-group"><label for="categories" class=" form-control-label">Categories</label>
                                  <input type="text" id="categories" name="categories" placeholder="Enter Categories  name" class="form-control" required value="<?php echo $categories ?>" ></div>
                               
                                <button id="payment-button" type="submit" name="submit" class="btn-btn-lg btn-info btn-block">
                                <span id="payment-button-amount">Submit</span>
                              </button>
                              <div class="field_error">  <?php echo $msg ?> </div>
                            </div>
                            </form>
                        </div>
                    </div>
 <?php 
     require('footer.php');
     
  ?>
                     