Advertisement
ridyko

edit.php ( Data Siswa )

Feb 3rd, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. <?php
  2.  include 'koneksi.php';
  3.  if(!isset($_GET['nis'])){
  4.  die("Error: NIS Tidak Dimasukkan");
  5.  }
  6.  $query = $db->prepare("SELECT * FROM `tbl_siswa` WHERE nis = :nis");
  7.  $query->bindParam(":nis", $_GET['nis']);
  8.  $query->execute();
  9.  if($query->rowCount() == 0){
  10.  die("Error: NIS Tidak Ditemukan");
  11.  }else{
  12.  $data = $query->fetch();
  13.  }
  14.  if(isset($_POST['submit'])){
  15.  $nama = htmlentities($_POST['nama']);
  16.  $alamat = htmlentities($_POST['alamat']);
  17.  $kelas = htmlentities($_POST['kelas']);
  18.  $query = $db->prepare("UPDATE `tbl_siswa` SET `nama`=:nama,`alamat`=:alamat,`kelas`=:kelas WHERE nis=:nis");
  19.  $query->bindParam(":nama", $nama);
  20.  $query->bindParam(":alamat", $alamat);
  21.  $query->bindParam(":kelas", $kelas);
  22.  $query->bindParam(":nis", $_GET['nis']);
  23.  $query->execute();
  24.  header("location: index.php");
  25.  }
  26. ?>
  27.  
  28. <!DOCTYPE html>
  29. <html>
  30.  <head>
  31.  <title>CRUD PDO quetkomputer.com </title>
  32.  <meta charset="utf-8">
  33.  </head>
  34.  <body bgcolor="#CCCCCC">
  35.  <h2><p align="center">EDIT DATA</p></h2>
  36.  <form method="post">
  37.  <table width="546" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" align="center">
  38.  <tr>
  39.  <td width="189" height="20"> </td>
  40.  <td width="26"> </td>
  41.  <td width="331"> </td>
  42.  </tr>
  43.  <tr>
  44.  <td height="27" align="right" valign="middle">NIS</td>
  45.  <td align="center" valign="top">:</td>
  46.  <td valign="middle">
  47.  <input type="text" name="nis" value="<?php echo $data['nis'] ?>" readonly="readonly">
  48.  </td>
  49.  </tr>
  50.  <tr>
  51.  <td height="27" align="right" valign="middle">Nama</td>
  52.  <td align="center" valign="top">:</td>
  53.  <td valign="middle"><label>
  54.  <input type="text" name="nama" value="<?php echo $data['nama'] ?>">
  55.  </label></td>
  56.  </tr>
  57.  <tr>
  58.  <td height="27" align="right" valign="middle">Alamat</td>
  59.  <td align="center" valign="top">:</td>
  60.  <td valign="middle"><label>
  61.  <input name="alamat" type="text" size="50" value="<?php echo $data['alamat'] ?>">
  62.  </label></td>
  63.  </tr>
  64.  <tr>
  65.  <td height="27" align="right" valign="middle">Kelas</td>
  66.  <td align="center" valign="top">:</td>
  67.  <td valign="middle"><label>
  68.  <input name="kelas" type="text" size="50" value="<?php echo $data['kelas'] ?>">
  69.  </label></td>
  70.  </tr>
  71.  <tr>
  72.  <td height="42"> </td>
  73.  <td> </td>
  74.  <td><input type="submit" name="submit" value="EDIT"></td>
  75.  </tr>
  76.  </table>
  77.  </form><p align="center"><a href=https://www.questkomputer.com/#>www.questkomputer.com</a></p>
  78.  </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement