Contoh Script Insert



FORM 


<!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="insertbarang.php">
<center><table width="500" height="200" border="10" cellpadding="10" cellspacing="5">
  <tr>
    <td>ID Izin</td>
    <td>:</td>
    <td><input type="text" name="id_izin"></td>
  </tr>
  <tr>
    <td>Nama</td>
    <td>:</td>
    <td><input type="text" name="nama"></td>
  </tr>
  <tr>
    <td>kelas</td>
    <td>:</td>
    <td><select name="kelas" id="kelas">
   <option value=" ">Kelas</option>
    <?php
  include 'koneksi.php';
  $query = mysqli_query($koneksi,"select * from kelas");
  while($data = mysqli_fetch_array($query))
  {
  echo"<option value='$data[0]'>$data[0]</option>";
           
  }

  ?>
    </select>
    </td>
    </tr>
  <tr>
    <td>Jurusan</td>
    <td>:</td>
    <td><select name="jurusan" id="jurusan">
    <option value=" ">Jurusan</option>
    <?php
    include 'koneksi.php';
    $query = mysqli_query($koneksi,"select * from jurusan");
    while($data = mysqli_fetch_array($query))
    {
    echo"<option value='$data[1]'>$data[1]</option>";
    }
    ?>
    </select>
    </td>
  </tr>
  <tr>
    <td>Stok Barang</td>
    <td>:</td>
    <td><input type="text" name="stok_barang"></td>
  </tr>
  <tr>
    <td colspan="3">
      <center><input type="submit" name="ok" value="OK">
      <input type="reset" name="cancel" value="CANCEL"></center>
    </td>
  </tr>
</table>
</center>
</form>

</body>
</html>





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


INSERT



<?php
include "koneksi.php";
$id_barang= $_POST ['id_barang'];
$jenis_barang = $_POST ['jenis_barang'];
$harga_beli= $_POST ['harga_beli'];
$harga_jual= $_POST ['harga_jual'];
$stok_barang= $_POST ['stok_barang'];
mysqli_query ($koneksi, "insert into barang values ('$id_barang', '$jenis_barang', '$harga_beli','$harga_jual','$stok_barang') ");
header ("location:showbarang.php");
?>

Comments

Popular posts from this blog

Contoh Script Search Dalam PHP

How to Download Touch Prodigy Not 3 Claw / Cara Download Touch Prodigy Bukan 3 Claw

Sudocreme Antiseptic Healing Cream