<?php 

session_start();
if (!isset($_SESSION['username'])) {
  header("location:login/main_login.php");
}
   
    // load up your config file
   require_once("setting.php");
	
    require_once(connection);
    require_once(header_p);
?>
<div class="container">
<div class="row justify-content-md-center">
<?php include_once(menu_penal);
?>
</div>
<div class="row justify-content-center">
    <div class="col-5">
  <h2>Enter Pkg Detail</h2></div></div>
  <form class="form-horizontal" action="" method="post">
    <div class="form-group">
		  <div class="form-row">

      <label for="disabledInput" class="col-sm-2 control-label">Pkg ID</label>
      <div class="col-sm-3">
        <input class="form-control" name="pkg_id" id="pkg_id" type="text" placeholder="" readonly>
      </div>
      <label class="col-sm-2 control-label">Pkg Name</label>
      <div class="col-sm-3">
        <input class="form-control" name="pkg_name" id="pkg_name" type="text" placeholder="Pkg Name">
      </div>
	  </div>
	  		  	  <div class="form-row">

  <label class="col-sm-2 control-label">Date</label>
      <div class="col-sm-3">
        <input class="form-control" name="pkg_date" id="pkg_date" type="date" placeholder="Date">
      </div>
	  <label class="col-sm-2 control-label">Price</label>
      <div class="col-sm-3">
        <input class="form-control" name="pkg_amount" id="pkg_amount" type="number" placeholder="amount">
      </div>
  </div>
			  <div class="form-row">

<label class="col-sm-2 control-label">Pkg Detail</label>
      <div class="col-sm-3">
	        <textarea class="form-control" rows="5" name="pkg_detail" id="pkg_detail"></textarea>

      </div>
  <label class="col-sm-2 control-label">Click</label>
	  <div class="col-sm-3">

   <input class="btn btn-primary" type="submit" name="submit" value="Update" />
      </div>
 
	  
	  </div>		

 </div>
  </form>
</div>


<?php
if(isset($_POST['submit'])){
$id= $_POST['pkg_id'];
$name= $_POST['pkg_name'];
$detail = $_POST['pkg_detail'];
$amount = $_POST['pkg_amount'];
$date = $_POST['pkg_date'];

$sql = "UPDATE pkg SET pkg_name = '$name', pkg_detail = '$detail', pkg_price = '$amount', pkg_date = '$date' WHERE pkg_id = '$id'";

if ($con->query($sql) === TRUE) {
	        echo '<script type="text/javascript">alert("New record:::' . $name . ':::created successfully"); </script>';

       unset($_POST['submit']);


} else {
    echo "Error: " . $sql . "<br>" . $con->error;
}

$con->close();
}
?>
</body>
</html>
