<?php

session_start();
require 'function.php';
require 'config.php';
$id = isset($_SESSION['id']);

if(isset($_POST['form_update'])) {

    $acara = $_POST['acara'];

    $jam = $_POST['jam'];

    $tanggal = $_POST['tanggal'];
    
    mysqli_query($koneksi,"UPDATE `event_id` SET acara='$acara', jam='$jam', tanggal='$tanggal'");
    
    echo '
    <script language="JavaScript">document.location="?info=valid"</script>
    ';
}

$result = mysqli_query($koneksi, "SELECT * FROM event_id" );

$whatsapp = mysqli_fetch_assoc($result);

$acara = $whatsapp['acara'];
$jam = $whatsapp['jam'];
$tanggal = $whatsapp['tanggal'];

require 'header.php';

?>


<body>

<?php
if(isset($_GET['info'])){
//   if(!empty($_GET['info'] == valid)){
    echo '
         <script>
        swal("Success","Update Success!","success");
          </script>
          
          ';
//   }
}  
?>   
<div class="container py-5 align-items-center mx-auto" style="width: 500px;">
   <div class="row p justify-content-center">
<h4 class="mb-3">Ganti Event</h4>
<p></p>
<form action="" method="POST" class="needs-validation" novalidate="">
        <div class="py-2">
          <label for="acara" class="form-label">Acara</label>
          <input type="text" class="form-control" name="acara" placeholder="" value="<?= $acara;?>" required="">
        </div>
        <div class="py-2">
          <label for="jam" class="form-label">Jam</label>
          <input type="text" class="form-control" name="jam" placeholder="" value="<?= $jam;?>" required="">
        </div>
        <div class="py-2">
          <label for="tanggal" class="form-label">Tanggal</label>
          <input type="text" class="form-control" name="tanggal" placeholder="" value="<?= $acara?>" required="">
        </div>
    <input type="hidden" name="form_update" value="1" />
      <button class="w-100 btn btn-danger btn-lg mt-2" type="submit">Update</button>
     </div>
</form>
 </div>
</div>
</div>
 
 </div>