SHARE
TWEET

PWD Erdi PHP

Erdi123 May 23rd, 2018 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 input_data.php
  2.  
  3. <link rel="stylesheet" href="style.css">
  4. <?php error_reporting(E_ALL & ~E_NOTICE); ?>
  5. <html>
  6. <head>
  7. <title>Form Biodata</title>
  8. </head>
  9. <body>
  10. <form id="form1" name="form1" method="post" action="simpan.php">
  11. <table border="1">
  12. <td>
  13.     <table width="800" align="center">
  14.         <tr><td height="24" colspan="3"align="center"><B>PENDAFTARAN</td></tr>
  15.         <tr><td>NIK</td><td align="center">:</td>
  16.             <td><input type="text" name="nik" id="nik"/></td></tr>
  17.         <tr><td>Nama</td><td align="center">:</td>
  18.             <td><input type="text" name="nama" id="nama"/></td></tr>
  19.         <tr><td>Jenis Kelamin</td><td align="center">:</td>
  20.         <td><input type="radio" name="jk" id="radio" value="PRIA" required />Pria
  21.             <input type="radio" name="jk" id="radio" value="WANITA" required />Wanita
  22.         </td>
  23.         <tr><td>Status</td><td align="center">:</td>
  24.         <td><input type="radio" name="status" id="radio" value="Menikah" required />Menikah
  25.             <input type="radio" name="status" id="radio" value="Lajang" required />Lajang
  26.         </td></tr>
  27.         </tr><tr><td>Tanggal Lahir</td><td align="center">:</td>
  28.             <td><input type="date" name="tanggal" required ></td></tr>
  29.         <tr><td colspan="2">&nbsp;</td>
  30.         <tr><td>alamat</td><td align="center">:</td>
  31.             <td><textarea name="alamat" id="alamat" required /></textarea></td>
  32.             <td><input type="submit" name="button" id="button" value="Simpan" />
  33.             <td>
  34.         </tr>
  35.     </table>
  36. <?php
  37. include"tabel_biodata.php";
  38. ?>
  39. </td>
  40. </table>
  41. </form>
  42. </body>
  43. </html>
  44.  
  45. -------------------------------------------------
  46.                         cetak_data.php
  47.  
  48. <?php
  49. $nama_dokumen='Cetak';
  50. define('_MPDF_PATH','mpdf60/');
  51. include(_MPDF_PATH . "mpdf.php");
  52. $mpdf=new mPDF('utf-8', 'A4');
  53. ob_start();
  54. ?>
  55. <html>
  56. <style>
  57. table, td, th {
  58.     border: 1px solid #ddd;
  59.     text-align: left;
  60. }
  61. table {
  62.     font-style: tahoma;
  63.     font-size: 11px;
  64.     border-collapse: collapse;
  65.     width: 100%;
  66. }
  67. th, td {
  68.     padding: 6px;
  69. }
  70. </style>
  71.  
  72. tes
  73.  
  74. <?php
  75. $html = ob_get_contents();
  76. ob_end_clean();
  77. $mpdf->WriteHTML(utf8_encode($html));
  78. $mpdf->Output($nama_dokumen.".pdf" ,'I');
  79. exit;
  80. ?>
  81.  
  82. -----------------------------------------------
  83.                             edit_data. php
  84.  
  85. <link rel="stylesheet" href="style.css">
  86. <?php
  87. error_reporting(E_ALL & ~E_NOTICE);
  88. include "koneksi.php";
  89. $nik=$_GET['id'];
  90. $cek_data="SELECT * FROM biodata WHERE nik='$nik'";
  91. $cek_query=mysqli_query($koneksi,$cek_data);
  92. $edit_data=mysqli_fetch_array($cek_query);
  93. ?>
  94. <html>
  95. <head>
  96. <title>Form Pendaftaran</title>
  97. </head>
  98. <body>
  99. <form id="form1" name="form1" method="post" action="update.php">
  100. <H1>EDIT BIODATA</H1>
  101. <table border="1" width="100%">
  102. <td>
  103.     <table width="800" align="center">
  104.    
  105.         <tr><td>NIK</td><td align="center">:</td>
  106.             <td><input type="text" name="nik" id="nik"
  107.             value="<?php print $edit_data[nik];?>" readonly /></td></tr>
  108.         <tr><td>Nama</td><td align="center">:</td>
  109.             <td><input type="text" name="nama" id="nama"
  110.             value="<?php print $edit_data[nama];?>"/></td></tr>
  111.         <tr><td>Jenis Kelamin</td><td align="center">:</td>
  112.         <td><input type="radio" name="jk" id="radio" value="PRIA" required />Pria
  113.             <input type="radio" name="jk" id="radio" value="WANITA" required />Wanita
  114.         </td>
  115.         <tr><td>Status</td><td align="center">:</td>
  116.         <td><input type="radio" name="status" id="radio" value="Menikah" required />Menikah
  117.             <input type="radio" name="status" id="radio" value="Lajang" required />Lajang
  118.         </td></tr>
  119.         <tr><td>Tanggal Lahir</td><td align="center">:</td>
  120.             <td><input type="date" name="tanggal"
  121.             value="<?php print $edit_data[ttl];?>"></td></tr>
  122.         <tr><td colspan="2">&nbsp;</td>
  123.         <tr><td>alamat</td><td align="center">:</td>
  124.         <td><textarea name="alamat" id="alamat">
  125.             <?php print $edit_data[alamat];?></textarea></td></tr>
  126.             <td><input type="submit" name="button" id="button" value="Simpan" />
  127.                 <a href="input_data.php">
  128.                 <input type="button" name="button2" id="button2" value="Batal" /><td>
  129.         </tr>
  130.     </table>
  131. <?php
  132. include"tabel_biodata.php";
  133. ?>
  134. </td>
  135. </table>
  136. </form>
  137. </body>
  138. </html>
  139.  
  140.     ---------------------------------------
  141.                             hapus_data. php
  142.  
  143. <?php
  144. include "koneksi.php";
  145. $nik    =$_GET['id'];
  146.  
  147. $update="Delete From biodata WHERE nik='$nik'";
  148. $query=mysqli_query($koneksi,$update);
  149.     if($query) {
  150.         ?>
  151.         <script> window.alert('Hapus Berhasil');
  152.                  window.location.href='input_data.php';</script>
  153.         <?php
  154.     }else{
  155.         ?>
  156.         <script> window.alert('Gagal di Hapus');
  157.                  window.location.href='input_data.php';</script>
  158.         <?php
  159.     }
  160. ?>
  161.  
  162. ----------------------------------------------
  163.                             koneksi. php
  164.  
  165. <?php
  166. $host="localhost";  //nama hostnya
  167. $user="root";       //nama user
  168. $pass="";           //password
  169. $db="db_erdi";      //nama database
  170. //koneksi database
  171. $koneksi=new mysqli($host, $user, $pass, $db);
  172. // cek koneksi
  173. if ($koneksi->connect_error) {
  174. die('maaf koneksi gagal:'.$koneksi->connect_error);}
  175. ?>
  176.  
  177. --------------------------------------------
  178.                         simpan.php
  179.  
  180. <?php
  181. include "koneksi.php";
  182. $nik=$_POST['nik'];
  183. $nama=$_POST['nama'];
  184. $jk=$_POST['jk'];
  185. $st=$_POST['status'];
  186. $ttl=$_POST['tanggal'];
  187. $alamat=$_POST['alamat'];
  188. //print "$nik, $nama, $jk, $st, $ttl";
  189. $simpan= "INSERT INTO biodata
  190.           (nik, nama, jk, ttl, status, alamat)VALUES
  191.           ('$nik','$nama','$jk','$ttl','$st','$alamat')";
  192.          
  193.     $query=mysqli_query($koneksi,$simpan);
  194.     if($query) {
  195.         ?>
  196.         <script> window.alert('Berhasil di Simpan');
  197.                  window.location.href='input_data.php';</script>
  198.         <?php
  199.     }else{
  200.         ?>
  201.         <script> window.alert('Gagal Simpan');
  202.                  window.location.href='input_data.php';</script>
  203.         <?php
  204.     }
  205. ?>
  206.  
  207. -----------------------------------------------
  208.                             tabel_biodata. php
  209.  
  210. <table border="1" width="100%">
  211.     <tr>
  212.         <th>No</th>
  213.         <th>NIK</th>
  214.         <th>Nama</th>
  215.         <th>JK</th>
  216.         <th>Tanggal Lahir</th>
  217.         <th>Status</th>
  218.         <th>Alamat</th>
  219.         <th>Action</th>
  220.     </tr>
  221.    
  222.     <?php
  223.     Include "koneksi.php";
  224.     $data="SELECT * FROM biodata";
  225.     $query_data=mysqli_query($koneksi,$data);
  226.     $no=1;
  227.     while ($tampil=mysqli_fetch_array($query_data) ) {
  228.     print"
  229.     <tr>
  230.     <td>$no</td>
  231.     <td>$tampil[nik]</td>
  232.     <td>$tampil[nama]</td>
  233.     <td>$tampil[jk]</td>
  234.     <td>$tampil[ttl]</td>
  235.     <td>$tampil[status]</td>
  236.     <td>$tampil[alamat]</td>
  237.     <td><a href=edit_data.php?id=$tampil[nik]>
  238.         <input type='button' name='edit' value='Ubah'></a>
  239.         <a href=hapus_data.php?id=$tampil[nik]>
  240.         <input type='button' name='hapus' value='Hapus'></a>
  241.         <a href=cetak_data.php?id=$tampil[nik]>
  242.         <input type='button' name='cetak' value='Print'></a></td>";
  243.         $no++;}?>
  244.     </tr>
  245. </table>
  246.  
  247. --------------------------------------------------
  248.                             update. php
  249.  
  250. <?php
  251. include "koneksi.php";
  252. $nik    =$_POST['nik'];
  253. $nama   =$_POST['nama'];
  254. $jk     =$_POST['jk'];
  255. $st     =$_POST['status'];
  256. $ttl    =$_POST['tanggal'];
  257. $alamat =$_POST['alamat'];
  258.  
  259. $update="UPDATE biodata SET nama='$nama', jk='$jk', status='$st', ttl='$ttl',
  260.         alamat='$alamat' WHERE nik='$nik'";
  261. $query=mysqli_query($koneksi,$update);
  262.     if($query) {
  263.         ?>
  264.         <script> window.alert('Berhasil di Update');
  265.                  window.location.href='input_data.php';</script>
  266.         <?php
  267.     }else{
  268.         ?>
  269.         <script> window.alert('Gagal di Update');
  270.                  window.location.href='input_data.php';</script>
  271.         <?php
  272.     }
  273. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top