0% found this document useful (0 votes)
60 views12 pages

Lampiran 4 Kode Program

1. The document contains code snippets from an PHP/MySQL based website for managing company profiles. It includes code for homepage, database connection, login page, session handling, adding/editing/deleting data pages and a CSS stylesheet. 2. The code snippets show the basic structure and functionality of different parts of the website - the homepage displays company profile data from the database, database connection code, login page code to authenticate users, use of sessions to restrict access, forms to add/edit data and delete functionality. 3. A CSS stylesheet is provided to style the different page elements like headers, menus, tables etc and apply basic layout and formatting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views12 pages

Lampiran 4 Kode Program

1. The document contains code snippets from an PHP/MySQL based website for managing company profiles. It includes code for homepage, database connection, login page, session handling, adding/editing/deleting data pages and a CSS stylesheet. 2. The code snippets show the basic structure and functionality of different parts of the website - the homepage displays company profile data from the database, database connection code, login page code to authenticate users, use of sessions to restrict access, forms to add/edit data and delete functionality. 3. A CSS stylesheet is provided to style the different page elements like headers, menus, tables etc and apply basic layout and formatting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

LAMPIRAN LISTING KODE PROGRAM

1. Halaman Utama (index.php)


<?php include "templates/header.html"; ?>
<?php include "templates/modul_kiri.html"; ?>
<td id="main">
<?php
include "fungsi/koneksi.php";
include "fungsi/format.php";
$idProfil = $_GET['id'];
$sqlTampil = "SELECT * FROM profil WHERE id='1'";
$qryTampil = mysql_query($sqlTampil, $koneksi)
or die ("Gagal query ".mysql_error());
while($dataTampil=mysql_fetch_array($qryTampil)) {
?>
<h1><?php echo "$dataTampil[judul]"; ?></h1>
<div class="isi">
<?php echo "$dataTampil[deskripsi]"; ?>
</div>
<?php } ?>
</td>
<?php include "templates/modul_kanan.html"; ?>
<?php include "templates/footer.html"; ?>

2. Halaman Konfigurasi (koneksi.php)


<?php
$my['host']
$my['user']
$my['pass']
$my['dbs']

=
=
=
=

"localhost";
"root";
"";
"wahyu";

$koneksi
= mysql_connect($my['host'], $my['user'],
$my['pass']);
if (! $koneksi) {
echo "Koneksi Gagal";
mysql_error();
}
// memilih database pda server
mysql_select_db($my['dbs'])

or die ("Database tidak ditemukan".mysql_error());


?>

3. Halaman Login
<html>
<head>
<title>Halaman Login</title>
<link rel="stylesheet" href="../templates/style.css"
type="text/css" media="screen" />
</head>
<body style="padding-top: 100px;">
<center>
<form action="loginPeriksa.php" method="post" name="form1"
target="_self" style="width: 380px; padding-top: 0px;">
<label><h1 style="text-align: center;">LOGIN
ADMINISTRATOR</h1></label><br />
<label><span style="width: 80px;">Username</span>
<input type="text" name="username" style="width:
280px;"/>
</label>
<label><span style="width: 80px;">Password</span>
<input type="password" name="password" style="width:
280px;"/>
</label>
<input type="submit" name="submit" value="Login"
class="tombol" />
<a href="../index.php"><input type="submit" name="submit"
value="Kembali" class="tombol" /></a>
</form>
</center>
</body>
</html>

4. Halaman Session (session.php)


<?php
session_start();
if(! (session_is_registered(SES_ADMIN))) {
include "login.php";
exit;
}
?>

5. Halaman Tambah Data


<?php include "templates/header.html"; ?>
<?php include "templates/modul_kiri.html"; ?>
<td id="main2">
<h1>Tambah Data Badan Usaha</h1>
<div class="isi">
<form action="bu_simpan.php" method="post" name="form1"
target="_self" style="width: 625px;">
<label><span>Nama Perusahaan</span><input type="text"
name="nm_per" size="48"/></label>
<label><span>Gred</span><select name="gred" style="margin-left:
0px;">
<option value="1" selected> Gred 1</option>
<option value="2">Gred 2</option>
<option value="3">Gred 3</option>
<option value="4">Gred 4</option>
<option value="5">Gred 5</option>
</select>
</label>
<label><span>Nama Pimpinan</span><input type="text"
name="pimpinan" size="48"/></label>
<label><span>Nomor Akaindo</span><input type="text"
name="no_akaindo"
size="30"/>Format:
<strong>07-17xxxxxx</strong></label>
<label><span>Nomor SBU</span><input type="text" name="no_sbu"
size="30"/>Format: <strong>2-17xx-x-xx-1-07-xxxxxx</strong></label>
<label><span>Keterangan</span><select name="ket" style="marginleft: 0px;">
<option value="Sudah Registrasi" selected>Sudah Registrasi</option>
<option value="Belum Registrasi">Belum Registrasi</option>
</select>
</label>
<a href="bu_tampil.php" style="text-decoration: none;"><input
name="Button" type="button" value="Kembali" class="tombol"/></a>
<input type="reset" value="Hapus" class="tombol"/>
<input type="submit" name="Submit" value="Simpan"
class="tombol"/>

</form>
</div>
</td>
<?php include "templates/footer.html"; ?>
6. Halaman Simpan Data
<body>
<?php
include "session.php";
include "../fungsi/koneksi.php";
$nm_per
= $_POST['nm_per'];
$gred
= $_POST['gred'];
$pimpinan = $_POST['pimpinan'];
$no_akaindo = $_POST['no_akaindo'];
$no_sbu = $_POST['no_sbu'];
$ket
= $_POST['ket'];
if (trim($nm_per) == "") {
echo 'Nama perusahaan masih kosong, <a href="javascript:history.go(1)"><strong>Koreksi</strong></a>';
}
else if (trim($pimpinan) == "") {
echo 'Nama pimpinan masih kosong, <a href="javascript:history.go(1)"><strong>Koreksi</strong></a>';
}
else if (trim($no_akaindo) == "") {
echo 'Nomor Akaindo masih kosong <a href="javascript:history.go(1)"><strong>Koreksi</strong></a>';
}
else if (trim($no_sbu) == "") {
echo 'Nomor SBU masih kosong <a href="javascript:history.go(1)"><strong>Koreksi</strong></a>';
}
else {
$sqlSimpan = "INSERT INTO badan_usaha SET
nm_per
gred
='$gred',
pimpinan ='$pimpinan',

='$nm_per',

no_akaindo ='$no_akaindo',
ket ='$ket',
no_sbu ='$no_sbu'";
mysql_query($sqlSimpan, $koneksi)
or die ("Gagal Perintah SQL". mysql_error());
# Jika sukses
echo '<div class="pesan">Data Badan Usaha berhasil ditambah</div>
';
include "bu_tampil.php";
}
?>
</body>
7. Halaman Hapus Data
<?php
include "session.php";
include "../fungsi/koneksi.php";
$id

= $_GET['id_bu'];

if (trim($id) == "") {
echo "Tidak ada data yang dihapus";
}
else {
$sqlHapus = "DELETE FROM badan_usaha WHERE id_bu='$id'";
mysql_query($sqlHapus, $koneksi)
or die ("Gagal Perintah SQL". mysql_error());
# Jika sukses
echo '<div class="pesan">Data berhasil dihapus</div> ';
include "bu_tampil.php";
}
?>
8. Halaman Style.css
body{
text-align: center;
font-family: verdana;
font-size: 12px;
line-height: 18px;
background: #FFFFFF url("images/bg.jpg") repeat-x;
}

a{
text-decoration: none;
color: #303169;
}
a:hover{
color: #D79A08;
text-decoration: underline;
}
h1{
font-size: 13px;
margin: 10px 5px 0 5px;
padding: 5px;
text-align: center;
color: #303169;
background: #f0daa4;
text-transform:uppercase;
}
h2{
font-size: 15px;
color: #303169;
font-weight: bold;
text-align: left;
}
h4{
font-size: 10px;
color: #D79A08;
text-align: left;
margin-top: -10px;
margin-bottom: -10px;
}
p{
text-align: justify;
}
table, th, td{
border-collapse: collapse;
font-size: 12px;
border: none;

vertical-align:top;
text-align: center;
background-color:Transparent;
margin: 0 auto;
padding: 0px;
}
#header, #animasi, #menu, #main, #footer{
width: 900px;
}
#header{
height: 139px;
background: #2a67d6 url("images/header.gif") no-repeat;
}
#animasi{
height: 20px;
margin-top: 120px;
font-size: 13px;
font-weight: bold;
color: #d79a08;
}
#menu{
height: 35px;
background: #D79A08;
border-top: 3px solid #FFFFFF;
vertical-align: middle;
}
#modul{
background: #5082DD;
height: 300px;
width: 200px;
overflow: hidden;
z-index: 0;
}
#modul2{
background: #5082DD;
height: 300px;
width: 250px;
overflow: hidden;
z-index: 0;

}
.judul_modul{
margin-top: 10px;
padding: 5px 0 5px 0;
background: #2a67d6;
font-weight: bold;
font-size: 12px;
color: #D79408;
text-transform:uppercase;
}
.isi_modul{
padding: 2px;
text-align: left;
color: #FFFFFF;
}
#main{
background: #FFFFFF;
height: 300px;
width: 500px;
overflow: hidden;
z-index: 0;
}
#main2{
background: #FFFFFF;
height: 300px;
width: 650px;
overflow: hidden;
z-index: 0;
}
.isi{
padding: 5px;
text-align: left;
}
#footer{
height: 50px;
background: #2a67d6;
border-top: 3px solid #D79A08;
vertical-align: middle;
font-size: 10px;
color: #FFFFFF;

}
#menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu ul li {
display: block;
position: relative;
float: left;
}
#menu li ul {
display: none;
}
#menu ul li a {
display: block;
text-decoration: none;
color: #ffffff;
padding: 5px 40px 5px 40px;
background: #5082dd;
margin-left: 17px;
white-space: nowrap;
text-transform:uppercase;
}
#menu ul li a:hover {
background: #f0daa4;
color: #303169;
}
#navigation ul {
margin:0px;
padding:0px;
}
#navigation ul li {
line-height:20px;
list-style:none;
padding-left:10px;
border-bottom:#fff solid 1px;
overflow: hidden;
z-index: 0;
}

#navigation ul li a {
color:#FFF;
text-decoration:none;
}
#navigation ul li:hover {
background-color:#D79a08;
position:relative;
}
.tabel table
{
border-collapse: collapse;
margin: 1px;
width:auto;
font-size: 12px;
}
.tabel table, .tabel tr, .tabel th, .tabel td
{
background-color:Transparent;
font-size: 12px;
padding: 2px;
line-height: 18px;
}
.tabel th, .tabel td
{
padding: 2px;
border: solid 1px #D79A08;
vertical-align: top;
}
.tabel th
{
text-align:center;
vertical-align:middle;
padding: 2px;
background: #F0Daa4;
}
.tabel td{
text-align: left;
}

form{
margin: 10px 0 10px 0px;
padding: 10px 5px 50px 5px;
width: 97%;
border: solid 1px #D79a08;
font-size: 12px;
background: #FFFFFF;
line-height: 18px;
}
label{
width: 100%;
display: block;
}
span{
float: left;
text-align: left;
width: 140px;
margin-left: 10px;
}
textarea{
min-width: 300px;
min-height: 50px;
margin-left: 0px;
}
input{
margin-left: 0px;
}
.tombol{
width: 80px;
height: 30px;
float: right;
margin: 10px 10px 0 20px;
}
.pesan{
padding-top: 5px;
padding-bottom: 5px;
background: #5082dd;
font-weight: bold;
color: #FFFFFF;
width: 900px;

text-align: center;
margin: 0 auto;
}

You might also like