0% found this document useful (0 votes)
126 views10 pages

Nama File: Config - PHP

This document contains instructions and code for creating a basic PHP/MySQL-based application for managing electricity bill payments. It includes: 1) Configuration files for connecting to a MySQL database called "rek_listrik" and includes for authentication. 2) PHP code and HTML templates for a login page, dashboard, customer data entry, and basic navigation structure. 3) Suggestions for folder structure and additional files like headers, footers and CSS. 4) A sample database table structure for a "pelanggan" (customer) table to store customer data. The purpose is to provide a starting point and instructions for building out a basic post-paid electricity bill payment application with user
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views10 pages

Nama File: Config - PHP

This document contains instructions and code for creating a basic PHP/MySQL-based application for managing electricity bill payments. It includes: 1) Configuration files for connecting to a MySQL database called "rek_listrik" and includes for authentication. 2) PHP code and HTML templates for a login page, dashboard, customer data entry, and basic navigation structure. 3) Suggestions for folder structure and additional files like headers, footers and CSS. 4) A sample database table structure for a "pelanggan" (customer) table to store customer data. The purpose is to provide a starting point and instructions for building out a basic post-paid electricity bill payment application with user
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Direktori/folder : uk2018 (atau didalam folder project masing2)

Nama file : config.php


<?php
mysql_connect("localhost","root","");
mysql_select_db("rek_listrik");
?>

Nama file : index.php


<!DOCTYPE html>
<html>
<head>
<title>Aplikasi Pembayaran Listrik Pasca Bayar</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="assets/js/jquery-ui/jquery-ui.css">
<script type="text/javascript" src="assets/js/jquery.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.js"></script>
<script type="text/javascript" src="assets/js/jquery-ui/jquery-ui.js"></script>
<?php

include 'config.php'; ?>


<style type="text/css">
.kotak{
margin-top: 150px;
}

.kotak .input-group{
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<?php
if(isset($_GET['pesan'])){
if($_GET['pesan'] == "gagal"){
echo "<div style='margin-bottom:-55px' class='alert alert-danger'
role='alert'><span class='glyphicon glyphicon-warning-sign'></span> Login Gagal !! Username dan
Password Salah !!</div>";
}
}
?>
<div class="panel panel-default">
<form action="login_act.php" method="post">
<div class="col-md-4 col-md-offset-4 kotak">
<h3>Silahkan Login ..</h3>
<div class="input-group">
<span class="input-group-addon"><span
class="glyphicon glyphicon-user"></span></span>
<input type="text" class="form-control"
placeholder="Username" name="uname">
</div>
<div class="input-group">
<span class="input-group-addon"><span
class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control"
placeholder="Password" name="pass">
</div>
<div class="input-group">
<input type="submit" class="btn btn-primary"
value="Login">
</div>
</div>
</form>
</div>
</div>
</body>
</html>

Nama file : login_act.php


<?php
session_start();
include 'config.php';
$uname=$_POST['uname'];
$pass=$_POST['pass'];
$pas=sha1($pass);
$query=mysql_query("select * from pengguna where nama_pengguna='$uname' and
password='$pas'")or die(mysql_error());
if(mysql_num_rows($query)==1){
$cek=mysql_fetch_array($query);
$_SESSION['uname']=$uname;
$_SESSION['level']=$query['level'];

if($cek['level']=="1")
{
mysql_query("update pengguna set status = '1' where
nama_pengguna='$uname'");
header("location:admin/index.php");
}
else if($cek['level']=="2")
{
mysql_query("update pengguna set status = '1' where
nama_pengguna='$uname'");
header("location:kasir/index.php");
}
else if($cek['level']=="3")
{
mysql_query("update pengguna set status = '1' where
nama_pengguna='$uname'");
header("location:petugas_meter/index.php");
}
}else{
header("location:index.php?pesan=gagal")or die(mysql_error());
// mysql_error();
}
// echo $pas;
?>

Buat struktur folder project nya seperti dibawah ini.

Buka folder admin

Nama File : header.php


<!DOCTYPE html>
<html>
<head>
<?php
session_start();
include 'cek.php';
include '../config.php';
?>
<title>Aplikasi Pembayaran Rekening Listrik </title>
<link rel="stylesheet" type="text/css" href="../assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../assets/js/jquery-ui/jquery-ui.css">
<script type="text/javascript" src="../assets/js/jquery.js"></script>
<script type="text/javascript" src="../assets/js/bootstrap.js"></script>
<script type="text/javascript" src="../assets/js/jquery-ui/jquery-ui.js"></script>
</head>
<body>
<div class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a href="localhost:8080/uk2018" class="navbar-brand">Pembayaran
Rekening Listrik</a>
<button type="button" class="navbar-toggle collapsed" data-
toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">

<li><a class="dropdown-toggle" data-toggle="dropdown"


role="button" href="#">User Login In : <?php echo $_SESSION['uname'] ?>&nbsp&nbsp<span
class="glyphicon glyphicon-user"></span></a></li>
</ul>
</div>
</div>
</div>

<div class="col-md-2">
<div class="row">
<?php
$use=$_SESSION['uname'];
$fo=mysql_query("select foto from pengguna where nama_pengguna='$use'");
while($f=mysql_fetch_array($fo)){
?>

<div class="col-xs-6 col-md-12">


<a class="thumbnail">
<img class="img-responsive" src="foto/<?php echo
$f['foto']; ?>">
</a>
</div>
<?php
}
?>
</div>

<div class="row"></div>
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="index.php"><span class="glyphicon glyphicon-
home"></span> Dashboard</a></li>
<li><a href="pelanggan.php"><span class="glyphicon glyphicon-
briefcase"></span> Data Pelanggan</a></li>
<li><a href="distributor.php"><span class="glyphicon glyphicon-briefcase"></span> Entry
Meteran</a></li>
<li><a href="jual.php"><span class="glyphicon glyphicon-briefcase"></span>
Rekening Listrik</a></li>
<li><a href="laporan_jual.php"><span class="glyphicon glyphicon-file"></span> Laporan
Peembayaran</a></li>

<li><a href="user.php"><span class="glyphicon glyphicon-user"></span> Manajemen


User</a></li>

<li><a href="ganti_foto.php"><span class="glyphicon glyphicon-


picture"></span> Ganti Foto</a></li>
<li><a href="ganti_pass.php"><span class="glyphicon glyphicon-lock"></span>
Ganti Password</a></li>
<li><a href="logout.php"><span class="glyphicon glyphicon-log-out"></span>
Logout</a></li>
</ul>
</div>
<div class="col-md-10">

Nama file : footer.php


</div>
</body>
</html>

Nama File : Index.php


<?php
include 'header.php';
?>

<?php
$a = mysql_query("select * from pelanggan");
?>

<div class="col-md-10">
<h3>Selamat datang</h3>
<h3>Aplikasi Pembayaran Listrik Pasca Bayar melalui Payment Point Online Bank</h3>
<h3>Dibuat Untuk Uji Kompetensi SMK Negeri 9 Medan</h3>
</div>
<!-- kalender -->
<div class="pull-right">
<div id="kalender"></div>
</div>

<?php
include 'footer.php';

?>

Dalam database, tambahkan tabel pelanggan dengan struktur berikut :

Nama File : pelanggan.php


<?php include 'header.php'; ?>

<h3><span class="glyphicon glyphicon-briefcase"></span> Data Pelanggan</h3>


<button style="margin-bottom:20px" data-toggle="modal" data-target="#myModal" class="btn btn-info
col-md-2"><span class="glyphicon glyphicon-plus"></span>Tambah Pelanggan</button>
<br/>
<br/>

<?php
$per_hal=10;
$jumlah_record=mysql_query("SELECT COUNT(*) from pelanggan");
$jum=mysql_result($jumlah_record, 0);
$halaman=ceil($jum / $per_hal);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
?>
<div class="col-md-12">
<table class="col-md-2">
<tr>
<td>Jumlah Record</td>
<td><?php echo $jum; ?></td>
</tr>
<tr>
<td>Jumlah Halaman</td>
<td><?php echo $halaman; ?></td>
</tr>
</table>
<a style="margin-bottom:10px" href="#" target="_blank" class="btn btn-default pull-
right"><span class='glyphicon glyphicon-print'></span> Cetak</a>
</div>
<form action="cari_act.php" method="get">
<div class="input-group col-md-5 col-md-offset-7">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-
search"></span></span>
<input type="text" class="form-control" placeholder="Masukkan ID Pelanggan di sini .."
aria-describedby="basic-addon1" name="cari">
</div>
</form>
<br/>
<table class="table table-hover">
<tr>
<th class="col-md-2">Id Pelanggan</th>
<th class="col-md-1">No Meter</th>
<th class="col-md-2">Nama</th>
<th class="col-md-2">Alamat</th>
<th class="col-md-1">Kota/Kab</th>
<th class="col-md-1">Kode Tarif</th>
<!-- <th class="col-md-1">Sisa</th> -->
<th class="col-md-6">Opsi</th>
</tr>
<?php
if(isset($_GET['cari'])){
$cari=mysql_real_escape_string($_GET['cari']);
$brg=mysql_query("select * from pelanggan where id_pelanggan like '$cari'");
}else{
$brg=mysql_query("select * from pelanggan limit $start, $per_hal");
}
while($b=mysql_fetch_array($brg)){

?>
<tr>
<td><?php echo $b['id_pelanggan'] ?></td>
<td><?php echo $b['no_meter'] ?></td>
<td><?php echo $b['nama'] ?></td>
<td><?php echo $b['alamat'] ?></td>
<td><?php echo $b['kota'] ?></td>
<td><?php echo $b['kode_tarif'] ?></td>

<td>
<a href="det_barang.php?id_buku=<?php echo $b['id_buku']; ?>"
class="btn btn-info">Detail</a>
<a href="edit_pelanggan.php?id_pelanggan=<?php echo
$b['id_pelanggan']; ?>" class="btn btn-warning">Edit</a>
<a onclick="if(confirm('Apakah anda yakin ingin menghapus data ini
??')){ location.href='hapus_pelanggan.php?id_pelanggan=<?php echo $b['id_pelanggan']; ?>' }"
class="btn btn-danger">Hapus</a>
</td>
</tr>
<?php
}
?>
</table>
<ul class="pagination">
<?php
for($x=1;$x<=$halaman;$x++){
?>
<li><a href="?page=<?php echo $x ?>"><?php echo $x ?></a></li>
<?php
}
?>
</ul>
<!-- modal input -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-
hidden="true">&times;</button>
<h4 class="modal-title">Tambah Pelanggan Baru</h4>
</div>
<form action="tmb_pelanggan_act.php" method="post">
<div class="form-group">
<label>No Meter</label>
<input name="no_meter" type="text" class="form-
control" placeholder="No Meter">
</div>
<div class="form-group">
<label>Nama</label>
<input name="nama" type="text" class="form-control"
placeholder="Nama">
</div>
<div class="form-group">
<label>Alamat</label>
<input name="alamat" type="text" class="form-control"
placeholder="Alamat">
</div>
<div class="form-group">
<label>Kota/Kab</label>
<input name="kota" type="text" class="form-control"
placeholder="Kota/Kab">
</div>
<div class="form-group">
<label>Jenis Tarif</label>
<select class="form-control" name="tarif"
id=tarif>
<?php
$tarif=mysql_query("select * from
tarif");
while($b=mysql_fetch_array($tarif)){
?>
<option value="<?php echo
$b['kode_tarif']; ?>"><?php echo $b['kode_tarif'];?></option>
<?php
}
?>
</select>
</div>

<div class="form-group">
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</form>
</div>
</div>

<?php
include 'footer.php';

?>

Nama File : tmb_pelanggan_act.php


<?php
include '../config.php';

$qry="SELECT max(id_pelanggan) as maxFaktur FROM pelanggan";


$hasil = mysql_query($qry);
$data = mysql_fetch_array($hasil);
if ($data) {
$nilaikode = substr($data[0], 1);
// menjadikan $nilaikode ( int )
$kode = (int) $nilaikode;
// setiap $kode di tambah 1
$kode = $kode + 1;
$kode_otomatis = "12".str_pad($kode, 9, "0", STR_PAD_LEFT);
} else {
$kode_otomatis = "12000000001";
}
$id_pelanggan=$kode_otomatis;
$no_meter=$_POST['no_meter'];
$nama=$_POST['nama'];
$alamat=$_POST['alamat'];
$kota=$_POST['kota'];
$tarif=$_POST['tarif'];

mysql_query("insert into pelanggan (id_pelanggan,no_meter,nama,alamat,kota,kode_tarif)


values('$id_pelanggan','$no_meter','$nama','$alamat','$kota','$tarif')");
header("location:pelanggan.php");

?>

You might also like