Anda di halaman 1dari 8

CARA MEMBUAT APLIKASI INVOICE DENGAN PHP DAN MYSQL

Pertama-tama kita download Xampp, notepad programers dan admin panel (untuk halaman
client dan admin sesuai keinginan). Kemudian install Xampp dan notepad programers.
Setelah semua terinstall, maka kita aktifkan xampp dengan meng-klik xampp-control.exe
yang ada di c:\\xampp lalu kita klik start pada module apache dan mysql kemudian tutup.
Setelah module apache dan mysql diaktifkan, kita buka folder htdocs yang ada di
c:\\xampp\htdocs dan buat folder baru dengan nama invoice, sehingga menjadi
c:\\xampp\htdocs\invoice, lalu buka folder invoice tersebut.
Langkah selanjutnya, kita copy paste admin panel yang tadi didownload kedalam folder
invoice. Dalam hal ini, pada halaman client saya menggunakan admin panel horizontal-
admin. Sehingga menjadi gambar seperti dibawah ini :

Selanjutnya, kita rename file index.html menjadi homeclient.php kemudian buka


menggunakan notepad programers.
Setelah file index.php terbuka dengan notepad programers, maka akan tampil source code
dari halaman admin panel tersebut. Selanjutnya kita rubah terlebih dahulu beberapa text
seperti header, menu, footer dan lain sebagainya sesuai dengan yang diinginkan.

Kemudian edit dan sesuaikan dengan file-file lainnya, sehingga menjadi seperti ini :

Setelah seluruh file kita edit dan telah sesuai maka kita lakukan pengkodingan agar aplikasi
dapat bekerja dengan baik, berikut sebagian contoh source code yang telah ditambahkan
pada file – file tersebut :
Bagian Atas pada homeclient.php agar apabila client tidak ada aktivitas pada aplikasi
selama 1 menit, maka aplikasi akan secara otomatis logout :
<?php
session_start();
$timeout = 1; // Set timeout menit
$logout_redirect_url = "login.php"; // Set logout URL

$timeout = $timeout * 60; // Ubah menit ke detik


if (isset($_SESSION['start_time'])) {
$elapsed_time = time() - $_SESSION['start_time'];
if ($elapsed_time >= $timeout) {
session_destroy();
echo "<script>alert('Session Anda Telah Habis!'); window.location =
'$logout_redirect_url'</script>";
}
}
$_SESSION['start_time'] = time();
?>
<?php
include('log.php');
?>

Halaman Ubah Password Client :


<form id="contactform" action="perusahaan_proses_pass.php" role="form"
method="post">
<?php
include "koneksi.php";
$kode_perusahaan= $_GET['kode_perusahaan'];
$query = "SELECT * FROM user where
id='$kode_perusahaan'";
$sql = mysql_query ($query);
$row=mysql_fetch_array($sql);
?>
<div class="form-group has-success">
<td><b>ID </b></td>
<td><b>:</b></td>
<input type="text" class="form-control"
name="kode_perusahaan" value="<?php echo $row['id'];?>" readonly="true"/>
<div class="validation">
</div>
</div>
<div class="form-group has-success">
<td><b>Username</b></td>
<td><b>:</b></td>
<input type="text" class="form-control"
name="nm_penanggung" value="<?php echo $row['username'];?>" readonly="true" />
<div class="validation">
</div>
</div>
<div class="form-group has-success">
<td><b>Password Lama</b></td>
<td><b>:</b></td><br>
<input type="password" class="form-
control" name="pass_lama" value="" required/>
<div class="validation">
</div>
</div>
<div class="form-group has-success">
<td><b>Password Baru</b></td>
<td><b>:</b></td><br>
<input type="password" class="form-
control" name="pass_baru" value="" required/>
<div class="validation">
</div>
</div>
<div class="form-group has-success">
<td><b>ketik Ulang Password</b></td>
<td><b>:</b></td><br>
<input type="password" class="form-
control" name="pass_baru2" value="" required/>
<div class="validation">
</div>
</div>
<div class="col-lg-12 field"><br>
<p>
<button class="btn btn-theme
margintop10 pull-left" type="submit" name="insert" Value="Insert">Update </button>
</p>
</div>
</div>
</form>

Halaman view.php untuk melihat file invoice yang akan didownload oleh client :
<table width="50%" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>No</th>
<th>No Informasi</th>
<th>Nama File</th>
<th>Type File</th>
<th>Size</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<?php
include "koneksi.php";
$sql="SELECT * from upload
where id='".$_SESSION['iduser']."'";
$tampil=mysql_query($sql);
$no=1;

while($hasil=mysql_fetch_array($tampil)){
?>
<tr class="success">
<td><?php echo $no?></td>
<td><?php echo
$hasil['no_informasi']?></td>
<td><?php echo $hasil['file']?
></td>
<td><?php echo $hasil['type']?
></td>
<td><?php echo $hasil['size']?
></td>
<td><a href="admin/file/<?php
echo $hasil['file'] ?>" target="_blank">view file</td>
</tr>
<?php
$no++;
}
?>
</tbody>
</table>

File logout.php berfungsi agar client apabila meng-klik tombol logout maka otomatis
client akan keluar dan diarahkan ke halaman login.php
<?php
session_start();
$_SESSION['pengguna']="";
unset($_SESSION['username']);
session_destroy();
echo "<script>
window.location = 'login.php';
</script>";
?>

Anda mungkin juga menyukai