LAMPIRAN : LISTING PROGRAM
1.
Index.php
:
<?php session_start();
?><!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>Latihan Psikometri</title>
<meta name="keywords" content="glossy box, web design, colorful background, free templates, website templates, CSS, HTML" /> <meta name="description" content="Glossy Box | free website template with a colorful background" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.ennui.contentslider.css" rel="stylesheet" type="text/css" media="screen,projection" />
</head> <body>
<div id="templatemo_wrapper_outer"> <div id="templatemo_wrapper">
<?php include "header.php"; ?>
<div id="templatemo_slider_wrapper"> <?php include "slider.php"; ?>
</div><!-- End cs_wrapper --> </div><!-- End contentslider -->
<!-- Site JavaScript -->
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.ennui.contentslider.js"></script> <script type="text/javascript"> $(function() {
$('#one').ContentSlider({ width : '940px',
height : '240px', speed : 400,
easing : 'easeOutSine' });
}); </script>
<script src="js/jquery.chili-2.2.js" type="text/javascript"></script>
<script src="js/chili/recipes.js" type="text/javascript"></script>
<div class="cleaner"></div> </div>
</div>
<div id="templatemo_content_wrapper">
<?php $p=$_REQUEST['p'];
if($p) {
include "$p"; }
else {
<div id="templatemo_content_wrapper_bottm"></div>
<div id="templatemo_footer">
Copyright © 2013 <a href="#">Latihan Psikometri</a> | by Febrina </a>
</div>
</div> <!-- end of wrapper --> </div> <!-- end of wrapper_outer -->
</body> </html>
2.
User2.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>Latihan Psikometri</title>
<meta name="keywords" content="glossy box, web design, colorful background, free templates, website templates, CSS, HTML" /> <meta name="description" content="Glossy Box | free website template with a colorful background" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.ennui.contentslider.css" rel="stylesheet" type="text/css" media="screen,projection" />
<body>
<div id="templatemo_wrapper_outer"> <div id="templatemo_wrapper">
<?php include "header.php"; ?>
<div id="templatemo_slider_wrapper"> <?php include "slider.php"; ?>
</div><!-- End cs_wrapper --> </div><!-- End contentslider -->
<!-- Site JavaScript -->
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.ennui.contentslider.js"></script> <script type="text/javascript"> $(function() {
$('#one').ContentSlider({ width : '940px',
height : '240px', speed : 400,
easing : 'easeOutSine' });
}); </script>
<script src="js/jquery.chili-2.2.js" type="text/javascript"></script>
<div class="cleaner"></div>
</div>
</div>
<div id="templatemo_content_wrapper">
<div id="content">
<div class="col_w560">
<form action="cek.php" method="post"> <table border="0" cellspacing="0" cellpadding="10">
<tr>
<td><h2>Username</h2></td> <td><h2>:</h2></td>
<td><h2><input type="text" name="username1"/></h2></td> </tr>
<tr>
<td><h2>Password</h2></td> <td><h2>:</h2></td>
<td><h2><input type="password" name="password1"/></h2></td> </tr>
</table>
<input type="submit" value="masuk"/> </form>
</div>
<div class="col_w280">
</div>
</div>
<div class="cleaner"></div>
</div>
<div id="templatemo_content_wrapper_bottm"></div>
<div id="templatemo_footer">
Copyright © 2013 | by Febrina </div>
</div> <!-- end of wrapper --> </div> <!-- end of wrapper_outer -->
</body> </html>
3.
Cek.php :
<?php
include("koneksi_user.php");
$username=$_REQUEST['username1']; $password=$_REQUEST['password1'];
if($username!=''& $password!='') {
$sql= "SELECT * FROM user where username='$username' AND password='$password'";
if($hasil['username']==$username && $hasil['password']==$password)
{
if($hasil['status']=='admin') {
session_start();
$_SESSION['pengguna']=$hasil['username'];
$_SESSION['id']=$hasil['id_user'];
header ("location:admin/index.php"); }
if($hasil['status']=='member') {
session_start();
$_SESSION['pengguna']=$hasil['username']; $_SESSION['id']=$hasil['id_member']; header ("location:member/index.php"); }
} else {
?>
<script type="text/javascript"> <!--
alert("Your name or password is wrong..") window.location = "index.php";
//--> </script> <?php }
} else {
<script type="text/javascript"> <!--
alert("Silahkan Login.")
window.location = "../index.php"; //-->
</script> <?php
}?>
4.
Soal.php
<form action="proses_soal.php" method="post">
<table border="0" cellspacing="0" cellpadding="10"> <tr>
<td>soal</td> <td>:</td>
<td><input type="text" name="soal"/></td> </tr>
<tr>
<td>pilihan A</td> <td>:</td>
<td><input type="text" name="pilihan_A"/></td> </tr>
<tr>
<td>pilihan B</td> <td>:</td>
<td><input type="text" name="pilihan_B"/></td> </tr>
<tr>
<td>pilihan C</td> <td>:</td>
<td>pilihan D</td> <td>:</td>
<td><input type="text" name="pilihan_D"/></td> </tr>
<tr>
<td>category</td> <td>:</td>
<td><?php include ("koneksi_user.php");
$sql=mysql_query("select * from category_soal"); ?>
<select name="category">
<?php while ($h=mysql_fetch_array($sql)) {?>
<option value="<?php echo $h['id_category_soal'];?>"><?php echo $h['category_soal']; ?>
</option> <?php } ?> </select>
</td> </tr><tr>
<td>Kunci</td> <td>:</td> <td>
<input type="radio" id="Kunci Jawaban" name="kunci" value="A" />A <input type="radio" id="Kunci Jawaban" name="kunci" value="B" />B <input type="radio" id="Kunci Jawaban" name="kunci" value="C" />C <input type="radio" id="Kunci Jawaban" name="kunci" value="D" />D
</td> </tr>
</tr> </table>
</form>
<?php
include "koneksi_user.php";
$sql = mysql_query("SELECT * FROM soal s, category_soal c where s.id_category_soal=c.id_category_soal");
?><script type="text/JavaScript"> <!--
function MM_popupMsg(msg) { //v1.0 alert(msg);
}
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'"); }
//-->
</script> <?php
//menentukan batas, cek dan posisi data $batas=5;
$halaman = $_REQUEST['halaman'];
if(empty($halaman)){ $posisi=0; $halaman = 1; } else {
//sesuaikan perintah SQL dengan posisi dan batas
$sql= "SELECT * FROM soal s, category_soal c where
s.id_category_soal=c.id_category_soal ORDER BY s.id_soal DESC LIMIT $posisi,$batas";
$result = mysql_query($sql); $test=mysql_num_rows($result); if ($test!=0)
{
$no=$posisi+1;
echo"
<table width='800' bordercolordark='#000000' cellpadding='1' cellspacing='1' bordercolor='#000000' border='0'
style='color:#000000'>";
echo" <tr align='center' bgcolor='#1083D8' style='color:#ffffff'>";
echo "<th>NO</th>"; echo "<th>Soal</th>"; echo "<th>Jawaban A</th>"; echo "<th>Jawaban B</th>"; echo "<th>Jawaban C</th>"; echo "<th>Jawaban D</th>"; echo "<th>Kunci</th>"; echo "<th>Category</th>"; echo "<th>Action</th></tr>";
while($row=mysql_fetch_array($result)) {
//pemberian warna berbeda pada tiap baris tampilan if (($no % 2)==0)
$id= $row['id_soal'];
echo "<tr bgcolor=$warna align='center' ><td>"; echo $no;
echo "</td><td width=''>"; echo $row['soal'];
echo "</td><td width=''>"; echo $row['A'];
echo "</td><td width=''>"; echo $row['B'];
echo "</td><td width=''>"; echo $row['C'];
echo "</td><td width=''>"; echo $row['D'];
echo "</td><td width=''>"; echo $row['kunci'];
echo "</td><td width=''>"; echo $row['category_soal'];
echo "</td><td width=''>";
echo "<a href='delete_soal.php?id=$row[id_soal]' onClick=\"return confirm('Apakah Anda benar-benar akan menghapus data
ini?')\"><acronym title='Hapus data'><img src='images/delete.png' width='20' height='20' alt='delete'></a> ";
?>
<acronym title="Edit Data"><a
href="index.php?p=edit_soal.php&id=<?php echo $id; ?>">Edit</a></acronym>
<style type="text/css"> <!--
a:link {
}
a:visited {
text-decoration: none; }
a:hover {
text-decoration: none; }
a:active {
text-decoration: none; }
--> </style> <?php $no++; }
echo "</table><table width='500' align='left' id='tabel_show' cellpadding='1' cellspacing='1'><tr><td></td><td>";
$sql2 = mysql_query("SELECT * FROM soal s, category_soal c where s.id_category_soal=c.id_category_soal");
$result=mysql_num_rows($sql2); $jmlhalaman=ceil($result/$batas);
/* bangun Previous link */ if($halaman > 1){
$prev = ($halaman - 1); ?>
<a href="index.php?p=soal.php&halaman=1"> << First </a> |
<a href="index.php?p=soal.php&<? echo "halaman=$prev"; ?>"> <<Previous </a>
echo "<p>First| < Previous "; } //tampilkan link halaman 1,2,3...
for($i = 1; $i <= $jmlhalaman; $i++){ if($i == $halaman){
echo "$i "; }
else { ?>
<a href="index.php?p=soal.php&<? echo "halaman=$i"; ?>"><? echo $i; ?></a>
<?php } }
/* bangun Next link */ if($halaman < $jmlhalaman){ $next = $halaman + 1;
?>
<a href="index.php?p=soal.php&<? echo "halaman=$next"; ?>">Next> |</a>
<a href="index.php?p=soal.php&<? echo "halaman=$jmlhalaman"; ?>">Last >></a> <?php }
echo "</td></tr></table>";
}//akhir dari kondisi bahwa data tidak kosong else { echo "<p>TIDAK ADA DATA DALAM DATABASE "; }
?>
5.
Member.php
<?php include "koneksi_user.php";?>
<tr>
<td>nama</td> <td>:</td>
<td><input type="text" name="nama"/></td> </tr>
<tr>
<td>alamat</td> <td>:</td>
<td><input type="text" name="alamat"/></td> </tr>
<tr>
<td>kota</td> <td>:</td>
<td><select name="kota"> <?php
$k = mysql_query("select * from kota"); while($a=mysql_fetch_array($k)){?>
<option value="<?php echo
$a['id_kota'];?>"><?php echo $a['nama_kota'];?></option> <?php }
?>
</select> </td>
</tr> <tr>
<td>email</td> <td>:</td>
<td><input type="varchar" name="email"/></td> </tr>
<tr>
<td><input type="text" name="tanggal_lahir"/></td> </tr>
<tr>
<td>jenis kelamin</td> <td>:</td>
<td><input type="radio" name="jkelamin" value="1"/>pria</td> <td><input type="radio" name="jkelamin"
value="0"/>wanita</td> </tr>
</table>
<input type="submit" value="simpan"/> </form>
<?php
$sql = mysql_query("SELECT * FROM member,kota where member.id_kota=kota.id_kota");
?><script type="text/JavaScript"> <!--
function MM_popupMsg(msg) { //v1.0 alert(msg);
}
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'"); }
//-->
//menentukan batas, cek dan posisi data $batas=5;
$halaman = $_REQUEST['halaman'];
if(empty($halaman)){ $posisi=0; $halaman = 1; } else {
$posisi = ($halaman-1) * $batas; }
//sesuaikan perintah SQL dengan posisi dan batas
$sql= "SELECT * FROM member,kota where member.kota=kota.id_kota ORDER BY id DESC LIMIT $posisi,$batas";
$result = mysql_query($sql); $test=mysql_num_rows($result); if ($test!=0)
{
$no=$posisi+1;
echo"
<table width='800' bordercolordark='#000000' cellpadding='1' cellspacing='1' bordercolor='#000000' border='0'
style='color:#000000'>";
echo" <tr align='center' bgcolor='#1083D8' style='color:#ffffff'>";
echo "<th>NO</th>"; echo "<th>Nama</th>"; echo "<th>Alamat</th>"; echo "<th>Email</th>"; echo "<th>Kota</th>";
while($row=mysql_fetch_array($result)) {
//pemberian warna berbeda pada tiap baris tampilan if (($no % 2)==0)
{ $warna="#DBDBDB"; } else { $warna="#ffffff";}
$id= $row['id'];
echo "<tr bgcolor=$warna align='center' ><td>"; echo $no;
echo "</td><td width=''>"; echo $row['nama'];
echo "</td><td width=''>"; echo $row['alamat'];
echo "</td><td width=''>"; echo $row['email'];
echo "</td><td width=''>"; echo $row['nama_kota'];
echo "</td><td width=''>";
echo "<a href='delete_member.php?id=$id' onClick=\"return confirm('Apakah Anda benar-benar akan menghapus data
ini?')\"><acronym title='Hapus data'><img src='images/delete.png' width='20' height='20' alt='delete'></a> ";
?>
<acronym title="Edit Data"><a
href="index.php?p=edit.php&id=<?php echo $id; ?>">Edit</a></acronym>
<style type="text/css"> <!--
a:link {
}
a:visited {
text-decoration: none; }
a:hover {
text-decoration: none; }
a:active {
text-decoration: none; }
--> </style> <?php $no++; }
echo "</table><table width='500' align='left' id='tabel_show' cellpadding='1' cellspacing='1'><tr><td></td><td>";
$sql2 = mysql_query("select * from member,kota where member.kota=kota.id_kota");
$result=mysql_num_rows($sql2); $jmlhalaman=ceil($result/$batas);
/* bangun Previous link */ if($halaman > 1){
$prev = ($halaman - 1); ?>
<a href="index.php?p=member.php&halaman=1"> << First </a> |
<a href="index.php?p=member.php&<? echo "halaman=$prev"; ?>"> <<Previous </a>
echo "<p>First| < Previous "; } //tampilkan link halaman 1,2,3...
for($i = 1; $i <= $jmlhalaman; $i++){ if($i == $halaman){
echo "$i "; }
else { ?>
<a href="index.php?p=member.php&<? echo "halaman=$i"; ?>"><? echo $i; ?></a>
<?php } }
/* bangun Next link */ if($halaman < $jmlhalaman){ $next = $halaman + 1;
?>
<a href="index.php?p=member.php&<? echo "halaman=$next"; ?>">Next> |</a>
<a href="index.php?p=member.php&<? echo "halaman=$jmlhalaman"; ?>">Last >></a>
<?php }
echo "</td></tr></table>";
}//akhir dari kondisi bahwa data tidak kosong else { echo "<p>TIDAK ADA DATA DALAM DATABASE "; }
?>
6.
Acc.php:
<?php session_start(); $id=$_SESSION['id'];
$a=mysql_query("select * from member where id='$id'"); $sql=mysql_fetch_array($a);
?>
<form action="accproses.php" method="post">
<table border="0" cellspacing="0" cellpadding="10"> <tr>
<td>username</td> <td>:</td>
<td><input type="text" name="username1" value="<?php echo "$sql[username]"; ?>"/></td>
</tr> <tr>
<td><input type="hidden" name="id" value="<?php echo "$sql[id] ";?>"></td>
</tr> <tr>
<td>password baru</td> <td>:</td>
<td><input type="password" name="password2"/></td> </tr>
<tr>
<td align="right" colspan="3"><input type="submit" value="ganti"/></td></tr>
</table>
</form> </body> </html>
7.
Koneksi_user.php
:<?php
$password="";
$koneksi=mysql_connect("$host","$user","$password");
$database=mysql_select_db("psikometri");
?>
8.
member /Soal.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" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css"/>
<title>Untitled Document</title> </head>
<body>
<form action="soal_proses.php" method="post"> <center>
<a href="index.php?p=soal.php&cat=verbal"><button type="button">Kategori Verbal</button></a>
<a href="index.php?p=soal.php&cat=kuantitatif"><button type="button">Kategori Kuantitatif</button></a>
<a href="index.php?p=soal.php&cat=deret"><button type="button">Kategori Deret Hitung</button></a>
<?php
if(!isset($_GET['cat'])){} else{
if($_GET['cat'] == 'verbal'){ $h = "Soal Verbal"; $cat=11;}
elseif($_GET['cat'] == 'kuantitatif'){$h = "Soal Kuantitatif"; $cat=12;}
elseif($_GET['cat'] == 'deret'){$h = "Soal Deret Hitung"; $cat=13; }
?>
<h1><?php echo $h;?></h1> </center>
<table border="0" cellspacing="0" cellpadding="10"> <?php
include "koneksi_user.php"; $p=$_SESSION['id'];
$s=mysql_query("SELECT * FROM soal s, category_soal c where s.id_category_soal=c.id_category_soal and
s.id_category_soal='$cat' order by id_soal desc limit 10"); $r=1;
while ($w=mysql_fetch_array($s)) {
?> <tr>
<td><input type="hidden" name="soal<?php echo $r;?>" value="<?php echo $w['id_soal']; ?>" />
<input type="hidden" name="category" value="<?php echo $h;?>" />
<?php echo $r.") ".$w['soal']; ?></td> </tr>
<tr><td>A.
<?php if ($w['kunci']=="A"){ ?> value="10" <?php } else {?> value="0"<?php } ?> />
<?php echo $w['A']; ?></td></tr> <tr><td>B.
<input type="radio" id="Kunci Jawaban" name="kunci<?php echo $r;?>"
<?php if ($w['kunci']=="B"){ ?> value="10" <?php } else {?> value="0"<?php } ?> /><?php echo $w['B']; ?></td></tr> <tr><td>C.
<input type="radio" id="Kunci Jawaban" name="kunci<?php echo $r;?>"
<?php if ($w['kunci']=="C"){ ?> value="10" <?php } else {?> value="0"<?php } ?> />
<?php echo $w['C']; ?></td></tr> <tr><td>D.
<input type="radio" id="Kunci Jawaban" name="kunci<?php echo $r;?>"
<?php if ($w['kunci']=="D"){ ?> value="10" <?php } else {?> value="0"<?php } ?> />
<?php echo $w['D']; ?>
<br/></td></tr>
<?php $r++; } ?> </table>
<input type="submit" value="simpan"/> </form>