Cara
Sederhana untuk belajar php
Coding
koneksi
<?php
$server="localhost";
$user="root";
$pass="";
$dbname="lising";
mysql_connect($server,$user,$pass) or die ("Koneksi
gagal");
mysql_select_db($dbname) or die ("database tidak bisa
dibuka");
?>
Coding-coding untuk membuat form atau input
<?php
include "koneksi.php";
echo
"<br><br><center><h1><font face='lucida
calligraphy' color='black'>Input Data Baru</font></h1>";
echo "
<form action='simpan.php'
method='POST'>
<body bgcolor='aqua'>
<table border='2'>
<tr>
<tr>
<td><font face='kristen itc'
color='black'>nomorbayar</td>
<td><input type=text
name='nomorbayar' size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>tglbayar</td>
<td><input type=text
name='tglbayar' size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>tglkrd</td>
<td><input type=text
name='tglkrd'size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>kodekredit</td>
<td><input type=text
name='kodekredit' size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>jumlah</td>
<td><input type=text name='jumlah'
size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>sisa</td>
<td><input type=text name='sisa'
size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>cicilan</td>
<td><input type=text name='cicilan'
size=20></td>
<tr>
<td><font face='kristen itc'
color='black'>keterangan</td>
<td><input type=text
name='keterangan' size=20></td>
<tr>
<td> </td>
<td><center><input
type='submit' value='simpan' method='POST'> <input type='reset' value='cancel'></center></td>
</tr>";
?>
Coding
simpan
<?
include "koneksi.php";
$qry=mysql_query("insert into
nomorbayar
(nomorbayar,tglbayar,tglkrd,kodekredit,jumlah,sisa,cicilan,keterangan)
values
('$_POST[nomorbayar]','$_POST[tglbayar]','$_POST[tglkrd]','$_POST[kodekredit]','$_POST[jumlah]','$_POST[sisa]','$_POST[cicilan]','$_POST[keterangan]')");
if ($qry)
echo "<h1> Data 'BERHASIL'
Disimpan</h1>";
else
echo "<h1> Data 'GAGAL'
Disimpan</h1>";
echo "<meta http-equiv=refresh
content= 1;URL=tampilnama.php>";
?>
Coding tampil
<?
include "koneksi.php";
echo"<br><center><h2><font
face='lucida calligraphy' color='white'>TAMPIL DATA BATAR
CICILAN</font></h2>";
echo"
<body bgcolor='aqua'>
<table border=1>
<tr>
<th><font face='kristen itc'
color='white'>No</th>
<th><font face='kristen itc'
color='white'>nomorbayar</th>
<th><font face='kristen itc'
color='white'>tglbayar</th>
<th><font face='kristen itc'
color='white'>tglkrd</th>
<th><font face='kristen itc'
color='white'>kodekredit</th>
<th><font face='kristen itc'
color='white'>jumlah</th>
<th><font face='kristen itc'
color='white'>sisa</th>
<th><font face='kristen itc'
color='white'>cicilan</th>
<th><font face='kristen itc'
color='white'>keterangan</th>
<th><font face='kristen itc' color='white'>Aksi</th></tr>";
$tampil=mysql_query("select *from
bayarcicilan");
$posisi=0;
$no=$posisi+1;
while($r=mysql_fetch_array($tampil)){
echo"
<tr>
<td><font
color='white'>$no</td>
<td><font
color='white'>$r[nomorbayar]</td>
<td><font
color='white'>$r[tglbayar]</td>
<td><font
color='white'>$r[tglkrd]</td>
<td><font
color='white'>$r[kodekredit]</td>
<td><font
color='white'>$r[jumlah]</td>
<td><font
color='white'>$r[sisa]</td>
<td><font
color='white'>$r[cicilan]</td>
<td><font
color='white'>$r[keterangan]</td>
<td><a
href=edit.php?nomorbayar=$r[nomorbayar]> Edit </a> ||
<a
href=hapus.php?nomorbayar=$r[nomorbayar]> Hapus</a></td>
</tr>";
$no++;
}
echo"
</table>";
if ($_GET[aksi]=='berhasil'){
echo "<h1> Anda Telah Berhasil Memperbaharui
Data</h1>";}
elseif ($_GET[aksi]=='hapus'){
echo "<h1> Anda Telah Berhasil Membuang
Data</h1>";}
echo"<br>
<center><a href='form.php'>Tambah
Data</a></center>";
?>
0 komentar:
Posting Komentar