Membuat Aplikasi Tabungan Siswa menggunakan PHP MYSQL












Langkah Membuat Aplikasi Tabungan Siswa menggunakan PHP MYSQL :

1. Buatlah Database dengan nama Kas_siswa

2. Buat Tablenya : siswa, setoran,penarikan


3.  Buatlah Trigger Setoran dan Penarikan



Fungsi Trigger diatas adalah untuk update Stock di table SISWA pada saat terjadi Setoran dan penarikan tabungan

4. Listing Program

koneksi.php

<?php
$host='localhost';
$user='root';
$pass='';
$db='kas_siswa';
mysql_connect($host,$user,$pass) or die ("Tidak dapat terkoneksi " . mysql_error());
mysql_select_db($db) or die ("Database tidak ditemukan " . mysql_error());
?>

input_setoran.php

<!DOCTYPE html>
<html>
<head>
<title>Setoran</title>
</head>
<body>
<center>
<br>
<form action="simpan_setoran.php" method="POST">
<table width="400" border="0" align="center" cellpadding="1"
                cellspacing="1" bordercolor="#00FF00" bgcolor="#33CC00">
<tr bgcolor="#CCFFCC">
<td height="50" colspan="3"><div align="center">INPUT DATA SETORAN </div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Id_setor</td>
<td>:<input type="text" name="id_setor" readonly></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Tanggal_setor</td>
<td>:<input type="date" name="tgl_setor" value="<?php echo date('Y-m-d'); ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">nis</td>
<td>:
<select name="nis">
<option>--Pilih NIS--</option>
<?php
include 'koneksi.php';
$query=mysql_query("SELECT * FROM siswa");
while ($datsiswa=mysql_fetch_array($query)) {
echo '<option value="'.$datsiswa['nis'].'">'.$datsiswa['nis'].'  '.$datsiswa['nama'].'</option>';
}
?>
</select>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td height="40">Jumlah setor</td>
<td>: <input type="text" name="jml_setor"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="50" colspan="3"><div align="center">
<input type="submit" name="Submit" value="Simpan Data"></div>
</td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>

simpan_setoran.php

<?php
include ("koneksi.php");
        $id_setor=$_POST['id_setor'];
        $tgl_setor=$_POST['tgl_setor'];
$nis=$_POST['nis'];
$jml_setor=$_POST['jml_setor'];

$simpan="insert into setoran values('$id_setor','$tgl_setor','$nis',$jml_setor)"; 
mysql_query($simpan);
echo "data berhasil disimpan ";
echo "<a href=tampil_setor.php>back</a>";
?>


input _penarikan.php

<!DOCTYPE html>
<html>
<head>
<title>Penarikan</title>
</head>
<body>
<center>
<br>
<form action="simpan_penarikan.php" method="POST">
<table width="400" border="0" align="center" cellpadding="1"
                cellspacing="1" bordercolor="#00FF00" bgcolor="#33CC00">
<tr bgcolor="#CCFFCC">
<td height="50" colspan="3"><div align="center">INPUT DATA PENARIKAN </div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Id Tarik</td>
<td>:<input type="text" name="id_tarik" readonly></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">Tanggal Penarikan</td>
<td>:<input type="date" name="tgl_tarik" value="<?php echo date('Y-m-d'); ?>"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="40">nis</td>
<td>:
<select name="nis">
<option>--Pilih NIS--</option>
<?php
include 'koneksi.php';
$query=mysql_query("SELECT * FROM siswa");
while ($datsiswa=mysql_fetch_array($query)) {
echo '<option value="'.$datsiswa['nis'].'">'.$datsiswa['nis'].'  '.$datsiswa['nama'].'</option>';
}
?>
</select>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td height="40">Jumlah Tarik</td>
<td>: <input type="text" name="jml_tarik"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="50" colspan="3"><div align="center">
<input type="submit" name="Submit" value="Simpan Data"></div>
</td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>

simpan_penarikan.php

<?php
include ("koneksi.php");
        $id_tarik=$_POST['id_tarik'];
        $tgl_tarik=$_POST['tgl_tarik'];
$nis=$_POST['nis'];
$jml_tarik=$_POST['jml_tarik'];

$simpan="insert into penarikan values('$id_tarik','$tgl_tarik','$nis',$jml_tarik)"; 
mysql_query($simpan);
echo "data berhasil disimpan ";
echo "<a href=tampil_setor.php>back</a>";
?>


index.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Menu Utama</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>

<nav>
<ul>
<li><a href="#">Beranda</a></li>
<li><a href="#">Nasabah</a>
<ul>
<li><a href="input_siswa.php">Input Data</a></li>
<li><a href="laporan_saldo.php">Laporan</a></li>
</ul>
</li>
<li><a href="#">Transaksi</a>
<ul>
<li><a href="input_setoran.php">Setoran</a></li>
<li><a href="input_penarikan.php">Penarikan</a></li>
<li><a href="#">Laporan</a>
<ul>
<li><a href="lap_setoran.php">Lap.Setor</a></li>
<li><a href="lap_penarikan.php">Lap.penarikan</a></li>
</ul>
</li>
</ul>
</li>

<li><a href="#">Tentang</a>
    <ul>
<li><a href="#">Kontak</a></li>
<li><a href="#">Blog</a></li>
</ul>
</li>
</ul>
</nav>
</body>
</html>

style.php

body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote {
margin: 0; padding: 0; border: 0;
}

body {
background: #fff;
font-family: Helvetica, sans-serif; font-size: 18px; line-height: 24px;
}

nav {
margin: 100px auto;
text-align: center;
}

nav ul ul {
display: none;
}

nav ul li:hover > ul {
display: block;
}


nav ul {
background: #53bd84;
padding: 0 20px;
border-radius: 10px; 
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}

nav ul li {
float: left;
}
nav ul li:hover {
background: #666;
}
nav ul li:hover a {
color: #fff;
}

nav ul li a {
display: block; padding: 25px 40px;
color: #fff; text-decoration: none;
}


nav ul ul {
background: #53bd84; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #53bd84;
border-bottom: 1px solid #53bd84; position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #666;
}

nav ul ul ul {
position: absolute; left: 100%; top:0;
}


1 komentar: