Contoh Script Insert Dalam PHP



================================================================================================
PETUNJUK PENGGUNAAN!!!

TULISAN BERWARNA MERAH = DIGANTI SEPERTI APA KAMU MENAMAINYA SAAT MENYIMPAN SCRIPT KAMU DI HTDOCS.

TULISAN BERWARNA UNGU = DIGANTI NAMANYA SEPERTI KALIAN BAGAIMANA MENYIMPANNYA DALAM TABEL DATABASE LOCALHOST.

TULISAN BERWARNA HIJAU = DIGANTI BERDASARKAN NAMA TABEL YANG KALIAN GUNAKAN DI DATABASE LOCALHOST.

================================================================================================

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Izin</title>
</head>

<body>
<form method="post" action="insertanggota.php">
<center><table width="600" height="200" border="6" cellpadding="10" cellspacing="5">
  <tr>
    <td>ID Anggota</td>
    <td>:</td>
    <td><input type="text" name="id_anggota"></td>
  </tr>
  <tr>
    <td>Nama</td>
    <td>:</td>
    <td><input type="text" name="nama"></td>
  </tr>
  <tr>
    <td>Alamat</td>
    <td>:</td>
    <td><textarea name="alamat"></textarea></td>
  </tr>
  <tr>
    <td>Nomor Telepon</td>
    <td>:</td>
    <td><input type="text" name="no_telp"></td>
  </tr>
  <tr>
    <td>Tanggal Lahir</td>
    <td>:</td>
    <td><input type="date" name="ttl"></td>
  </tr>
 
  <tr>
    <td colspan="3">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" name="ok" value="OK">
  <input type="reset" name="cancel" value="CANCEL">
  </td>
</tr>

</table>
</center>
</form>
</body>
</html>


====================================================================================================================================================================================================

<?php
include "koneksi.php";
$id_anggota = $_POST ['id_anggota'];
$nama = $_POST ['nama'];
$alamat = $_POST ['alamat'];
$no_telp = $_POST ['no_telp'];
$ttl = $_POST ['ttl'];


mysqli_query ($koneksi, "insert into anggota values ('$id_anggota', '$nama','$alamat','$no_telp','$ttl') ");
header ("location:showanggota.php");
?>

Comments

Popular posts from this blog

Top 10 Comic, Manga, Manhwa (Part 1)