document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. // kalau tidak ada id di query string
  6. if( !isset($_GET[\'id\']) ){
  7.     header(\'Location: list-siswa.php\');
  8. }
  9.  
  10. //ambil id dari query string
  11. $id = $_GET[\'id\'];
  12.  
  13. // buat query untuk ambil data dari database
  14. $sql = "SELECT * FROM calon_siswa WHERE id=$id";
  15. $query = mysqli_query($db, $sql);
  16. $siswa = mysqli_fetch_assoc($query);
  17.  
  18. // jika data yang di-edit tidak ditemukan
  19. if( mysqli_num_rows($query) < 1 ){
  20.     die("data tidak ditemukan...");
  21. }
  22.  
  23. ?>
  24. <!DOCTYPE html>
  25. <html>
  26. <head>
  27.     <title>Formulir Pendaftaran Siswa Baru | SMK Coding</title>
  28.     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  29.     <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
  30.     <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
  31.     <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
  32. </head>
  33. <body>
  34.     <header>
  35.         <center><h3>Formulir Edit Data Siswa</h3></center>
  36.     </header>
  37.     <div class="container">
  38.         <form action="proses-edit.php" method="POST">
  39.             <fieldset>
  40.                 <input type="hidden" name="id" value="<?=$siswa[\'id\']?>" />
  41.                 <div class="mb-3">
  42.                     <label for="nama" class="form-label">Nama: </label>
  43.                     <input type="text" name="nama" placeholder="nama lengkap" class="form-control" value="<?=$siswa[\'nama\'];?>"/>
  44.                 </div>
  45.                 <p>
  46.                     <label for="alamat" class="form-label">Alamat: </label>
  47.                     <textarea name="alamat" class="form-control" placeholder="Masukkan Alamat"><?=$siswa[\'alamat\'];?></textarea>
  48.                 </p>
  49.                 <p>
  50.                     <label for="jenis_kelamin">Jenis Kelamin: </label>
  51.                     <?php $jk = $siswa[\'jenis_kelamin\']; ?>
  52.                     <label><input type="radio" name="jenis_kelamin" value="laki-laki" <?=(($jk==\'laki-laki\')?"checked":"")?>> Laki-laki</label>
  53.                     <label><input type="radio" name="jenis_kelamin" value="perempuan" <?=(($jk==\'perempuan\')?"checked":"")?>> Perempuan</label>
  54.                 </p>
  55.                 <p>
  56.                     <label for="agama">Agama: </label>
  57.                     <?php $agama = $siswa[\'agama\']; ?>
  58.                     <select name="agama">
  59.                         <option <?=(($agama == \'Islam\') ? "selected": "")?>>Islam</option>
  60.                         <option <?=(($agama == \'Kristen\') ? "selected": "")?>>Kristen</option>
  61.                         <option <?=(($agama == \'Hindu\') ? "selected": "")?>>Hindu</option>
  62.                         <option <?=(($agama == \'Budha\') ? "selected": "")?>>Budha</option>
  63.                         <option <?=(($agama == \'Atheis\') ? "selected": "")?>>Atheis</option>
  64.                     </select>
  65.                 </p>
  66.                 <p>
  67.                     <label for="sekolah_asal">Sekolah Asal: </label>
  68.                     <input type="text" name="sekolah_asal" placeholder="nama sekolah" value="<?=$siswa[\'sekolah_asal\']?>" />
  69.                 </p>
  70.                 <center>
  71.                     <input type="submit" value="Simpan" name="submit" class="btn btn-success" />
  72.                     <a href="list-siswa.php" class="btn btn-danger">Batal</a>
  73.                 </center>
  74.             </fieldset>
  75.  
  76.         </form>
  77.     </div>
  78. </body>
  79. </html>
');