Pada postingan ini admin akan menjelaskan tentang pembuatan Aplikasi Surat Keterangan Kuliah berbasis Web. Web yang dibuat menggunakan PHP dan database MySQL.
Untuk lebih jelasnya berikut akan dijelaskan langkah-langkah pembuatan aplikasinya.
1. Pembuatan Database
Tabel Mahasiswa dengan struktur tabel berikut :
Isi tabel tersebut dengan data berikut :
Tabel User dengan struktur tabel berikut :
Isi tabel tersebut dengan data berikut :
Berikut saya lampirkan source codenya :
Code dibawah di copy ke notepad kemudian anda simpan dengan ekstensi.php
- koneksi.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbnm = "db_datamhs";
$conn = mysql_connect ($host, $user, $pass);
if ($conn) {
$buka = mysql_select_db ($dbnm);
if (!$buka) {
die ("Database tidak dapat dibuka"); }
} else {
die ("Server MySQL tidak terhubung"); }
?>
- about.php
<style type="text/css">
<!--
.style2 {color: #000000}
-->
</style>
<div id="content">
<h2>Tentang Pemodifikasi Program</h2>
<p> </p>
<p>Nama : Taufik Falah, Asep Feri, Tatang Hidayat, dan Agustian Kusmana.</p>
<p>Mata Kuliah : Praktek Web Database</p>
</div>
- cetak.php
<?php
include("koneksi.php");
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
$nim = $_GET['nim'];
$query = "select * from tb_mahasiswa where nim='$nim'";
$result = mysql_query($query);
$data = mysql_fetch_array($result);
?>
<html>
<head>
<title>Surat Keterangan Masih Kuliah</title>
</head>
<body> <div id="content">
<img SRC="img/kop.png" width=700 height=180><br></center>
<center><img SRC="img/tes.png"><br></center>
<p> Ketua Sekolah Tinggi Manajemen dan Ilmu Komputer (STMIK) Sumedang dengan ini menerangkan bahwa : <br>
<p> NIM : <?php echo $data['nim'] ; ?><br>
Nama Lengkap : <?php echo $data['nama']; ?><br>
Tempat Lahir : <?php echo $data['tempat_lahir'] ; ?><br>
Tanggal Lahir : <?php echo $data['tanggal_lahir']; ?><br>
Alamat : <?php echo $data['alamat']; ?><br>
<p> Nama tersebut diatas adalah Mahasiswa Sekolah Tinggi Manajemen dan Ilmu Komputer (STMIK) Sumedang dan masih aktif dalam perkuliahan. Surat keterangan ini untuk keperluan <?php echo $data['keterangan']; ?>.<br>
<p> Demikianlah surat keterangan ini diberikan untuk dapat dipergunakan sebagaimana mestinya.
</div>
<br>
<script>
window.load = cetak();
function cetak(){
window.print();
}
</script>
<br>
<img SRC="img/kopi.png" width=600 height=190><br>
</div>
</center>
</body>
</html>
- delete.php
<?php
include "koneksi.php";
if (isset($_GET['nim'])) {
$nim = $_GET['nim'];
} else {
die ("Error. nim Selected! "); }
?>
<div id="content">
<?php
//proses delete berita
if (!empty($nim) && $nim != "") {
$query = "DELETE FROM mahasiswa WHERE nim='$nim'";
$sql = mysql_query ($query);
if ($sql) {
echo "<h2><font color=blue>Data telah berhasil dihapus</font></h2>"; }
else {
echo "<h2><font color=red>Data gagal dihapus</font></h2>"; }
echo "Klik <a href='index2.php?page=tampil'>di sini</a> untuk kembali ke tampilan surat keterangan";
} else {
die ("Access Denied"); }
?>
</div>
- delete-banyak.php
<?php
include "koneksi.php";
?>
<?php
$jumlah = count($_POST["item"]);
for($i=0; $i < $jumlah; $i++)
{
$nim=$_POST["item"][$i];
$res = mysql_query("select photo from tb_mahasiswa where nim='$nim' LIMIT 1");
$d=mysql_fetch_object($res);
if (strlen($d->photo)>3)
{
if (file_exists($d->photo)) unlink($d->photo);
}
$myquery = "delete from tb_mahasiswa where nim ='$nim' limit 1";
$hapus = mysql_query($myquery) or die ("gagal menghapus");
}
header ("location:index2.php?page=tampil");
?>
- form.html
<html>
<head>
<title>New Picture</title>
</head>
<body>
<form name=”form1″ action=”save-gallery.php” method=”post” enctype=”multipart/form-data”>
File: <input type=”file” name=”file” id=”file”/><br/>
Deskripsi: <textarea name=”deskripsi” id=”deskripsi”></textarea><br/>
<input type=”submit” name=”save” value=”Upload”/>
</form>
</body>
</html>
- hapus-data-mahasiswa.php
<?php
include "koneksi.php";
if(!isset($_SESSION['login'])) {
header("location:login-data-mahasiswa.php");
}
?>
<?php
$nim = $_GET['nim'];
$res = mysql_query("select photo from tb_mahasiswa where nim='".$_GET['nim']."' LIMIT 1");
$d=mysql_fetch_object($res);
if (strlen($d->photo)>3)
{
if (file_exists($d->photo)) unlink($d->photo);
} $myquery = "delete from tb_mahasiswa where nim ='$nim' limit 1";
$hapus = mysql_query($myquery) or die ("gagal menghapus");
header ("location:index2.php?page=tampil");
?>
- index2.php
<html>
<head>
<title>Aplikasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi </strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<a href="index3.php"><strong>Home</strong></a>
<a href="index2.php?page=input"><strong>Input Surat Keterangan</strong></a>
<a href="index2.php?page=tampil"><strong>Tampil Surat Keterangan</strong></a>
<a href="index2.php?page=about"><strong>About</strong></a>
<a href="index.php"><strong>Keluar</strong></a></div>
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input-data-mahasiswa.php"; break;
case 'cari' : include "laporan-data-mahasiswa.php"; break;
case 'edit' : include "edit.php"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "laporan-data-mahasiswa.php"; break;
case 'foto' : include "foto.php"; break;
case 'about' : include "about.php"; break;
default : include 'laporan-data-mahasiswa.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a> </div>
</div>
</body>
</html>
- index3.php
<html>
<head>
<title>Aplikasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi </strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<a href="index3.php"><strong>Home</strong></a>
<a href="index2.php?page=input"><strong>Input Surat Keterangan</strong></a>
<a href="index2.php?page=tampil"><strong>Tampil Surat Keterangan</strong></a>
<a href="index2.php?page=about"><strong>About</strong></a>
<a href="index.php"><strong>Keluar</strong></a></div>
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input-data-mahasiswa.php"; break;
case 'cari' : include "laporan-data-mahasiswa.php"; break;
case 'edit' : include "edit.php"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "laporan-data-mahasiswa.php"; break;
case 'foto' : include "foto.php"; break;
case 'about' : include "about.php"; break;
default : include 'menu.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a> </div>
</div>
</body>
</html>
- index4.php
<html>
<head>
<title>Aplikasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi </strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input.php"; break;
case 'cari': include "cari_peg.php"; break;
case 'edit' : include "edit.php"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "tampil.php"; break;
case 'foto' : include "foto.php"; break;
case 'about' : include "about.php"; break;
default : include 'utamagagal.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a> </div>
</div>
</body>
</html>
- index5.php
<html>
<head>
<title>Aplikasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi</strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<a href="index2.php"><strong>Home</strong></a>
<a href="index2.php?page=input"><strong>Input Surat Keterangan</strong></a>
<a href="index2.php?page=tampil"><strong>Tampil Surat Keterangan</strong></a>
<a href="index2.php?page=about"><strong>About</strong></a>
<a href="index.php"><strong>Keluar</strong></a></div>
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input.php"; break;
case 'cari': include "cari_peg.php"; break;
case 'edit' : include "edit.php"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "tampil.php"; break;
case 'foto' : include "foto.php"; break;
case 'koreksi' : include "koreksi-data-mahasiswa.php"; break;
case 'about' : include "about.php"; break;
default : include 'koreksi-data-mahasiswa.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a> </div>
</div>
</body>
</html>
- index6.php
<html>
<head>
<title>Aplikasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi</strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<a href="index3.php"><strong>Home</strong></a>
<a href="index2.php?page=input"><strong>Input Surat Keterangan</strong></a>
<a href="index2.php?page=tampil"><strong>Tampil Surat Keterangan</strong></a>
<a href="index2.php?page=about"><strong>About</strong></a>
<a href="index.php"><strong>Keluar</strong></a></div>
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input-data-mahasiswa.php"; break;
case 'cari' : include "laporan-data-mahasiswa.php"; break;
case 'edit' : include "koreksi-data-mahasiswa"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "laporan-data-mahasiswa.php"; break;
case 'foto' : include "foto.php"; break;
case 'about' : include "about.php"; break;
default : include 'koreksi-data-mahasiswa.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2013 <a href="titasitimartini@ymail.com">TATA</a> | Design By <a href="http://septa.net">TATA</a> </div>
</div>
</body>
</html>
- input-data-mahasiswa.php
<?php
include("koneksi.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Input Surat Keterangan</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<form action="simpan-data-mahasiswa.php" method="post" enctype="multipart/form-data" name="FMHS">
<table width="452" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#669900">
<tr>
<td height="40" align="center" bgcolor="#669900"><strong><font color="#FFFFFF">Input Surat Keterangan</font></strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="452" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="113">NIM</td>
<td width="11">:</td>
<td width="237"><input name="nim" type="text" id="nim" size="12" maxlength="12"></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="nama" type="text" id="nama" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Tempat Lahir</td>
<td>:</td>
<td><input name="tempat_lahir" type="text" id="tempat_lahir" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Tanggal Lahir</td>
<td>:</td>
<td><select name="tgl" size="1" id="tgl">
<?php
for ($i=1;$i<=31;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
<select name="bln" size="1" id="bln">
<?php
$bulan=array("","Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
for ($i=1;$i<=12;$i++)
{
echo "<option value=".$i.">".$bulan[$i]."</option>";
}
?>
</select>
<select name="thn" size="1" id="thn">
<?php
for ($i=1985;$i<=2000;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select></td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><textarea name="alamat" cols="30" rows="5" id="alamat"></textarea></td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td><input name="keterangan" type="radio" value="Pengajuan Beasiswa" checked> Pengajuan Beasiswa</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" type="radio" value="Kenaikan Gaji PNS"> Kenaikan Gaji PNS </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" type="radio" value="Ijin Observasi"> Ijin Observasi </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" type="radio" value="Ijin Penelitian"> Ijin Penelitian </td>
</tr>
<tr>
<td>Photo</td>
<td>:</td>
<td><input type="file" name="photo" id="photo"></td>
</tr>
<tr>
<td colspan="3" align="center"><input name="fok" type="submit" id="fok" value="OK">
<input name="fulang" type="reset" id="fulang" value="Ulangi">
<input name="fulang2" type="button" id="fulang2" value="Batal" onClick="javascript:history.back()"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
- koreksi-data-mahasiswa.php
<?php
include("koneksi.php");
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Koreksi Mahasiswa</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<?php
$nim=$_GET['nim'];
$qrykoreksi=mysql_query("select * from tb_mahasiswa where nim='$nim' LIMIT 1");
$dataku=mysql_fetch_object($qrykoreksi);
list($tahun,$bulan,$tanggal) = explode('-',$dataku->tanggal_lahir);
?>
<form action="update-data-mahasiswa.php" method="post" enctype="multipart/form-data" name="FKoreksi">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#669900">
<tr>
<td height="50" align="center" bgcolor="#669900"><strong><font color="#FFFFFF">KOREKSI DATA</font></strong></td>
</tr>
<tr>
<td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="99">NIM</td>
<td width="9">:</td>
<td width="287"><input name="nim" type="text" id="nim" size="10" maxlength="10" value="<?php echo $dataku->nim?>" readonly=""></td>
<td width="163" rowspan="7" align="center" valign="top"><img src="<?php echo $dataku->photo?>" alt="<?php echo $dataku->nama?>" width="100" border="1"/></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="nama" type="text" id="nama" size="30" maxlength="30" value="<?php echo $dataku->nama?>"></td>
</tr>
<tr>
<td>Tempat Lahir</td>
<td>:</td>
<td><input name="tempat_lahir" type="text" id="tempat_lahir" size="30" maxlength="30" value="<?php echo $dataku->tempat_lahir?>"></td>
</tr>
<tr>
<td>Tanggal Lahir</td>
<td>:</td>
<td><select name="tgl" size="1" id="tgl">
<?php
for ($i=1;$i<=31;$i++)
{
if($tanggal==$i) {
echo "<option value=".$i." selected>".$i."</option>";
} else {
echo "<option value=".$i.">".$i."</option>";
}
}
?>
</select>
<select name="bln" size="1" id="bln">
<?php
$namabulan=array("","Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
for ($i=1;$i<=12;$i++)
{
if($bulan==$i) {
echo "<option value=".$i." selected>".$namabulan[$i]."</option>";
} else {
echo "<option value=".$i.">".$namabulan[$i]."</option>";
}
}
?>
</select>
<select name="thn" size="1" id="thn">
<?php
echo "<option value=".$tahun.">".$tahun."</option>";
for ($i=1985;$i<=2000;$i++)
{
if($tahun==$i) {
echo "<option value=".$i." selected>".$i."</option>";
} else {
echo "<option value=".$i.">".$i."</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><textarea name="alamat" cols="30" rows="5" id="alamat"><?php echo $dataku->alamat?></textarea></td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td><input name="keterangan" id="keterangan" type="radio" value="Pengajuan Beasiswa" <?php if($dataku->keterangan=='Pengajuan Beasiswa') echo "checked";?>>
Pengajuan Beasiswa</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" id="keterangan" type="radio" value="Kenaikan Gaji PNS" <?php if($dataku->keterangan=='Kenaikan Gaji PNS') echo "checked";?>>
Kenaikan Gaji PNS</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" id="keterangan" type="radio" value="Ijin Observasi" <?php if($dataku->keterangan=='Ijin Observasi') echo "checked";?>>
Ijin Observasi</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> <input name="keterangan" id="keterangan" type="radio" value="Ijin Penelitian" <?php if($dataku->keterangan=='Ijin Penelitian') echo "checked";?>>
Ijin Penelitian </td>
</tr>
<tr>
<td>Photo</td>
<td>:</td>
<td><input type="file" name="photo" id="photo"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Pilih photo jika ingin diganti</td>
<td> </td>
</tr>
<tr>
<td height="50" colspan="4" align="center"><input name="fok" type="submit" id="fok" value="OK">
<input name="fulang" type="reset" id="fulang" value="Ulangi">
<input name="fulang" type="button" id="fulang" value="Batal" onClick="javascript:history.back()"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
- laporan.php
<html>
<head><title>Laporan Data Surat Keterangan Masih Kuliah</title></head>
<body>
<div id="content">
<center>
<img SRC="img/kop.png" width=1000 height=220><br>
<?php
include("koneksi.php");
$q = "SELECT * from tb_mahasiswa ";
$result = mysql_query($q);
echo "<center>";
echo "<h2> Laporan Data Surat Keterangan Masih Kuliah</h2>";
echo "<table border='1' cellpadding='1' cellspacing='0'>";
echo "
<tr bgcolor='#999999'>
<td align='center'>NO</td>
<td align='center'>NIM</td>
<td align='center'>NAMA</td>
<td align='center'>TEMPAT LAHIR</td>
<td align='center'>TANGGAL LAHIR</td>
<td align='center'>KETERANGAN</td>
<td align='center'>ALAMAT</td>
</tr>";
$no=1;
while($data = mysql_fetch_array($result))
{
echo "<tr>";
echo "<tr>";
echo "<td align='center'>" ; echo $no++; "</td>";
echo "<td align='center'>" ; echo $data['nim'] ; "</td>";
echo "<td align='center'>" ; echo $data['nama'] ; "</td>";
echo "<td align='center'>" ; echo $data['tempat_lahir'] ; "</td>";
echo "<td align='center'>" ; echo $data['tanggal_lahir'] ; "</td>";
echo "<td align='center'>" ; echo $data['keterangan'] ; "</td>";
echo "<td align='center'>" ; echo $data['alamat'] ; "</td>";
echo "</tr>";
}
echo "</table>";
?>
<script>
window.load = print_d();
function print_d(){
window.print();
}
</script>
<br>
<img SRC="img/kopi.png" width=700 height=190><br>
</center>
</div>
</body>
</html>
- laporan-data-mahasiswa.php
<?php
include("koneksi.php");
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
?>
<html>
<head>
<title>Laporan Data Mahasiswa</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2 align="center">Data Surat Keterangan </h2>
</a></p>
<form action="" method="get" name="FCari" id="FCari">
Cari NIM/Nama/Keterangan
<input name="txtcari" type="text" id="txtcari" size="20" maxlength="30" value="<?php echo $_GET['txtcari']?>">
<input type="submit" name="Submit" value="Cari">
</form>
<form name="FLaporan" method="post" action="delete-banyak.php" onSubmit="return confirm('Hapus data terpilih?')">
<table width="100%" border="1" align="center" cellpadding="3" cellspacing="0">
<tr>
<td align="center"> </td>
<td align="center">NIM</td>
<td align="center">Nama</td>
<td align="center">Tempat Lahir</td>
<td align="center">Tanggal Lahir</td>
<td align="center">Keterangan</td>
<td align="center">Alamat</td>
<td align="center">Photo</td>
<td align="center">Edit</td>
<td align="center">SKMK</td>
</tr>
<?php
$txtcari=$_GET['txtcari'];
if(isset($txtcari))
{
$myquery="select nim,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir, keterangan,alamat, photo from tb_mahasiswa where nim='$txtcari' or nama LIKE '%$txtcari%' or keterangan LIKE '%$txtcari%'";
}
else
{
$myquery="select nim,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir, keterangan,alamat, photo from tb_mahasiswa";
} $daftarsiswa=mysql_query($myquery) or die (mysql_error());
while($dataku=mysql_fetch_object($daftarsiswa))
{
?>
<tr>
<td align="center">
<input type="checkbox" name="item[]" id="item[]" value="<?php echo $dataku->nim?>" /></td>
<td align="center"><?php echo $dataku->nim?></td>
<td align="center"><?php echo $dataku->nama?></td>
<td align="center"><?php echo $dataku->tempat_lahir?></td>
<td align="center"><?php echo $dataku->tanggal_lahir?></td>
<td align="center"><?php echo $dataku->keterangan?></td>
<td align="center"><?php echo $dataku->alamat?></td>
<td align="center"><img src="<?php echo $dataku->photo?>" alt="<?php echo $dataku->nama?>" width="50" /></td>
<td align="center"><a href="index6.php?nim=<?php echo $dataku->nim?>">Edit</a></td>
<td align="center"><a href="cetak.php?nim=<?php echo $dataku->nim?>" target="output">Cetak</a></td>
</tr>
<?php
}
?>
</table>
</a></p>
<input name="btnHapus" type="submit" value="Delete">
</form>
<input type="button" onClick="laporan()" value="Cetak Laporan" >
<script>
function laporan(){
window.open("laporan.php","_blank");
}
</script>
</body>
</html>
- login.php
<html>
<head>
<title>Sistem Informasi</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
font-size: 36px
}
-->
</style>
</head>
<body>
<div id="main_container">
<div id="header">
<h2 align="center" class="style1"> </h2>
<h2 align="center" class="style1"><strong>Aplikasi</strong></h2>
<h2 align="center" class="style1"><strong>Surat Keterangan Masih Kuliah</strong></h2>
</div>
<div id="navigation"><marquee><Font color="#0000ff" Font Face="Calibri" size="4"><b>
SELAMAT DATANG DI APLIKASI SURAT KETERANGAN</b></font></marquee></td></td></tr></div>
<div id="navigation">
<a href="index.php"><strong>Home</strong></a>
<a href="index.php?page=input"><strong>Input Surat Keterangan</strong></a>
<a href="index.php?page=tampil"><strong>Tampil Surat Keterangan</strong></a>
<a href="index.php?page=about"><strong>About</strong></a></div>
<p>
<?php
$page = (isset($_GET['page']))? $_GET['page'] : "main";
switch ($page)
{
case 'input': include "input.php"; break;
case 'edit' : include "edit.php"; break;
case 'delete' : include "delete.php"; break;
case 'tampil' : include "tampil.php"; break;
case 'foto' : include "foto.php"; break;
case 'about' : include "about.php"; break;
default : include 'utama.php'; }
?>
</p>
<div id="footer"><marquee><Font color="#0000ff" Font Face="Calibri" size="1"><b>
© 2012 <a href="titasitimartini@ymail.com">septa</a> | Design By <a href="http://septa.net">septa</a></b></font></marquee>
</td></td></tr></div>
<div id="footer">© 2012 <a href="titasitimartini@ymail.com">septa</a> | Design By <a href="http://septa.net">septa</a> </div>
</div>
</body>
</html>
- login-data-mahasiswa.php
<?php
include("koneksi.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Pengguna</title>
<style type="text/css">
body {
margin:20px;
background-color:#f4f4f4;
}
#FormLogin {
width:400px;
margin:0 auto;
border:1px solid #444;
padding:20px;
background-color:#333;
border-radius:20px;
color:#fff;
}
#FormLogin h1 {
text-align:center;
border-bottom:1px solid #ccc;
padding:10px;
margin:5px;
;
font-size:22px;
}
#FormLogin label {
float:left;
width:150px;
}
#FormLogin .text {
margin-bottom:5px;
}
</style>
</head>
<body>
<?php
//Penangganan login jika form diisi
if(isset($_POST['username']) && isset($_POST['password']))
{
//cek isian
if(!empty($_POST['username']) && !empty($_POST['password']))
{
$username=htmlspecialchars(stripslashes($_POST['username']));
$password=md5(htmlspecialchars(stripslashes($_POST['password'])));
$myquery="select username,nama,DATE_FORMAT(login_terakhir, '%d-%m-%Y %H:%i:%s') as login_terakhir from tb_pengguna where username='$username' and password='$password' limit 1";
$result=mysql_query($myquery) or die (mysql_error());
if (mysql_num_rows($result) == 1)
{
//jika username dan password cocok
$pengguna=mysql_fetch_object($result);
$_SESSION['login']=true;
$_SESSION['username']=$pengguna->username;
$_SESSION['nama']=$pengguna->nama;
$_SESSION['login_terakhir']=$pengguna->login_terakhir;
mysql_query("update tb_pengguna set login_terakhir=NOW() where username='$username' limit 1") or die("Gagal memperbaharui terakhir login");
header("location:index.php");
} else {
//jika username dan password tidak cocok
echo "<h1 align=\"center\">Username atau password salah!</h1>";
}
} else {
//jika form kosong munculkan pesan
echo "<h1 align=\"center\">Isikan username dan password!</h1>";
}
}
?>
<div id="FormLogin">
<h1>LOGIN APLIKASI DATA MAHASISWA</h1>
<form id="FLogin" name="FLogin" method="post" action="">
<label>Username</label>
:
<input name="username" type="text" id="username" size="20" maxlength="20" class="text" />
<br />
<label>Password</label>
:
<input name="password" type="password" id="password" size="20" maxlength="20" class="text" />
<br />
<p align="center">
<input type="submit" name="button" id="button" value="Login" />
<input type="reset" name="Reset" id="button" value="Reset" />
</p>
</form>
</div>
</body>
</html>
- loginsubmit.php
<?php
// memulai session
session_start();
mysql_connect('localhost', 'root', '');
mysql_select_db('db_datamhs');
$username = $_POST['username'];
$password = $_POST['pass'];
// query untuk mendapatkan record dari username
$query = "SELECT * FROM user WHERE username = '$username'";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
// cek kesesuaian password
if ($password == $data['password'])
{
// menyimpan username dan level ke dalam session
$_SESSION['level'] = $data['level'];
$_SESSION['username'] = $data['username'];
// tampilkan menu
echo "<center>";
include "index3.php";
echo "</center>";
}
else
include "index4.php";
?>
- logout-data-mahasiswa.php
<?php
include "koneksi.php";
session_destroy();
header("location:login-data-mahasiswa.php");
?>
- menu.php
<div id="content">
<h2>Aplikasi Surat Keterangan Masih Kuliah STMIK Sumedang</h2>
<p> Aplikasi Surat Keterangan masih kuliah ini dimodifikasi untuk memenuhi Ujian Tengah Semester (UTS) Praktek mata kuliah Web Database, Teknik Informatika, STMIK Sumedang.</p>
<p>Dalam Aplikasi Surat Keterangan Masih Kuliah ini, Anda dapat membuat/mengajukan surat keterangan masih kuliah yang kemudian diotorisasi langsung oleh pihak lembaga STMIK Sumedang.</p>
<p><em>Modified By : TATA Team (Taufik Falah, Asep Feri, Tatang Hidayat, Agustian Kusmana).</em></p>
<p>Have a nice day!</p>
</div>
- proses.php
<?php
include"koneksi.php";
session_start();
if(isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$sql = mysql_query("SELECT * FROM user WHERE username='$username' &&
password='$password'");
$num = mysql_num_rows($sql);
if($num==1) {
$_SESSION['user'] = $username;
$_SESSION['passwd'] = $password;
?><script language="JavaScript">alert('Anda berhasil login');
document.location='tampil.php'</script><?php
} else {
?><script language="JavaScript">alert('Username & Password Salah');
document.location='index.php'</script><?php
}
}
?>
- simpan-data-mahasiswa.php
<?php
include "koneksi.php";
?>
<?php
$nim=$_POST['nim'];
$nama=$_POST['nama'];
$tempat_lahir=$_POST['tempat_lahir'];
$tanggal_lahir = $_POST['thn']."-".$_POST['bln']."-".$_POST['tgl'];
$alamat=$_POST['alamat'];
$keterangan=$_POST['keterangan'];
if (empty($nim))
{ die("Isikan NIM!");
}
elseif(empty($nama))
{
die("Isikan Nama!");
}
else
{
$cekdata="select nim from tb_mahasiswa where nim='$nim'";
$ada=mysql_query($cekdata) or die(mysql_error());
if(mysql_num_rows($ada)>0)
{ die("NIM telah Terdaftar!"); }
else
{
if (!empty($_FILES["photo"]["tmp_name"]))
{
$namafolder="photo/"; //tempat menyimpan file
$jenis_gambar=$_FILES['photo']['type'];
if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png")
{
$photo = $namafolder . basename($_FILES['photo']['name']);
if (!move_uploaded_file($_FILES['photo']['tmp_name'], $photo))
{
die("Gambar gagal dikirim");
}
}
else { die("Jenis gambar yang anda kirim salah. Harus .jpg .gif .png"); }
} //end if cek file upload
mysql_query("insert into tb_mahasiswa(nim,nama,tempat_lahir,tanggal_lahir,alamat,keterangan,photo) " .
"values('$nim','$nama','$tempat_lahir','$tanggal_lahir','$alamat','$keterangan','$photo')") or die(mysql_error());
echo "Berhasil";
header("location:index2.php?page=tampil");
} //end if terdaftar
} ?>
- style.css
/* CSS Document */
body {
background-color:#EFEFEF;
font-family:"Trebuchet MS", sans-serif;
}
a {
text-decoration: none;
color:#0000ff;
}
a:hover {
color:#ff0000;
}
#main_container {
width:1000px;
border: #000000 1px solid;
margin: 0 auto;
background-color:#FEFEFE;
}
#header {
height:174px;
width:100%;
background-image: url(images/clock.jpg);
background-repeat: no-repeat;
}
h1 {
size:30px;
float:right;
vertical-align:middle;
margin: 10px 20px 0 0;
font-family: Impact, Arial, Helvetica, sans-serif;
}
h2 {
padding-left: 5px;
margin: 5px 0px 0px 0px;
}
p, table {
size: 10px;
margin:0px;
padding:10px;
text-align:justify;
}
#navigation {
width:100%;
border-top: #000000 1px solid;
border-bottom: #000000 1px solid;
text-align:center;
}
#navigation a {
padding:3px;
}
#content {
width:100%;
}
#footer {
width:100%;
border-top: #000000 1px solid;
text-align:center;
font-size:9px;
}
#tabel {
background-color:#ffffff; padding:2px;
border:1px solid #222222;
margin:2px;
} #tabel th {
color:#ffffff;
background-color:#222222;
padding:2px; }
- update-data-mahasiswa.php
<?php
include "koneksi.php";
?>
<?php
$nim=$_POST['nim'];
$nama=$_POST['nama'];
$tempat_lahir=$_POST['tempat_lahir'];
$tanggal_lahir = $_POST['thn']."-".$_POST['bln']."-".$_POST['tgl'];
$alamat=$_POST['alamat'];
$keterangan=$_POST['keterangan'];
if (empty($nim))
{ die("Isikan NIM!");
}
elseif(empty($nama))
{
die("Isikan Nama!");
}
else //bisa tambahkan pengecekan yang lain jika perlu
{
//proses upload photo jika ada
if (!empty($_FILES["photo"]["tmp_name"]))
{
$namafolder="photo/"; //tempat menyimpan file
$jenis_gambar=$_FILES['photo']['type'];
if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png")
{
$photo = $namafolder . basename($_FILES['photo']['name']);
if (!move_uploaded_file($_FILES['photo']['tmp_name'], $photo))
{
die("Gambar gagal dikirim");
}
//Hapus photo yang lama jika ada
$res = mysql_query("select photo from tb_mahasiswa where nim='$nim' LIMIT 1");
$d=mysql_fetch_object($res);
if (strlen($d->photo)>3)
{
if (file_exists($d->photo)) unlink($d->photo);
} //update photo dengan yang baru
mysql_query("UPDATE tb_mahasiswa SET photo='$photo' WHERE nim='$nim' LIMIT 1");
}
else { die("Jenis gambar yang anda kirim salah. Harus .jpg .gif .png"); }
} //end if cek file upload
$myqry="UPDATE tb_mahasiswa SET nama='$nama',tempat_lahir='$tempat_lahir',".
"tanggal_lahir='$tanggal_lahir',alamat='$alamat',keterangan='$keterangan' WHERE nim='$nim' LIMIT 1";
mysql_query($myqry) or die(mysql_error());
header("location:index2.php?page=tampil");
exit;
} ?>
- utama.php
<html>
<head><title> Aplikasi Akademik </title><head>
<body>
<center>
<br><br>
<h3>Masukan Username dan Password</h3>
<form method="post" action="loginsubmit.php">
<table border="0">
<tr>
<td>Masukkan Username </td>
<td><input name="username" type="text"></td>
</tr>
<tr>
<td>Masukkan Password </td>
<td><input name="pass" type="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
- utamagagal.php
<html>
<head><title> Aplikasi Akademik </title><head>
<body>
<center>
<br><br>
<h3>Username / Password Anda Salah. Silakan Ulangi!</h3>
<form method="post" action="loginsubmit.php">
<table border="0">
<tr>
<td>Masukkan Username </td>
<td><input name="username" type="text"></td>
</tr>
<tr>
<td>Masukkan Password </td>
<td><input name="pass" type="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
Untuk melengkapi aplikasi diatas, Silahkan download file pendukung berikut :
0 Response to "Code Program Aplikasi Surat Keterangan Kuliah Berbasis Web"
Posting Komentar