Advertisement
ridyko

create.php ( Data Siswa )

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