LISTING PROGRAM
1. Tampilan Login ( login.php )
<!DOCTYPE html> <html>
<head>
<title>Login Forumsquare</title>
<link rel="icon" type="text/css" href="Logoiconfs.png"/> <style type="text/css">
body{
font-family: arial; font-size: 14px;
background-color: #457d9f; }
#utama{
width: 300px; margin: 0 auto; margin-top: 2%; }
#judul{
padding: 15px; text-align: center; color: #fff;
font-size: 20px;
background-color: #25719e; border-top-right-radius: 20px; border-top-left-radius: 20px; border-bottom: 3px solid #00598d; }
#input{
background-color: #eaeaec; padding: 20px;
border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; }
input{
padding: 10px; border: 0; }
button{
padding: 10px; border: 0; }
.userpass{ width: 240px; }
.button{
background-color: #25719e; border-radius: 10px;
width: 260px; color: #fff; }
background-color: #00598d; cursor: pointer;
} .a{
color: #ffffff; }
.b{
background-attachment: fixed; }
</style> </head>
<body class="b" background="images/bgforum5.jpg"> <div align="center">
<br /><img src="images/logoforumsquare.png" width="" height="" /><br />
</div>
<div id="utama"> <div id="judul">
Login Forumsquare </div>
<div id="input">
<form action="proseslogin.php" method="post" > <div>
<input type="text" name="username" placeholder="Username" class="userpass" required
oninvalid="this.setCustomValidity('Silahkan masukkan Username')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:10px;">
<input type="password" name="password" placeholder="Password" class="userpass" required
oninvalid="this.setCustomValidity('Silahkan masukkan Password')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:20px;">
<input type="submit" name="login" value="Login" class="button" />
</div>
<div style="margin-top:10px;">
<button type="button" value="" class="button"><a href="registrasi.php" style="text-decoration:none"
class="a">Signup</a></input> </div>
<div align="center" style="margin-top:10px"> <?php
if(isset($_GET['status'])){ $status = $_GET['status']; }
else{
$status = ""; }
echo "<blink>$status</blink>"; ?>
</div> </form> </div> </div>
</div> </body> </html>
2. Proses Login ( proseslogin.php )
<?php
session_start();
$username = $_POST['username']; $password = $_POST['password']; include("config.php");
if (empty($username) || empty($password)) {
header("location:login.php?status=*Semua field harus diisi");
} else{
$sql = "SELECT * FROM tabel_member WHERE username = '$username' AND password = '$password'";
$hasil = mysql_query($sql, $koneksi); $record = mysql_fetch_array($hasil); if($record['username'] == ""){
header("location:login.php?status=*Username dan Password tidak valid");
exit(); }
if($record['username']){
$_SESSION['username'] = $username; header ("location:index.php"); }
} ?>
3. Tampilan Signup ( registrasi.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>Signup Forumsquare</title>
<link rel="icon" type="text/css" href="Logoiconfs.png" /> <style type="text/css">
body{
font-family: arial; font-size: 14px;
background-color: #457d9f; }
#topbar{
padding: 10px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
position: fixed; top: 0;
left: 0; right: 0; }
#gambar{
padding-left: 50px; }
#utama{
width: 300px; margin: 0 auto; margin-top: 10%; }
#judul{
padding: 15px; text-align: center; color: #fff;
font-size: 20px;
background-color: #25719e; border-top-right-radius: 20px; border-top-left-radius: 20px; border-bottom: 3px solid #00598d; }
#input{
background-color: #eaeaec; padding: 20px;
border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; }
input{
padding: 10px; border: 0; }
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
background-color: #25719e; border-radius: 10px;
width: 260px; color: #fff; }
.button:hover{
background-color: #00598d; cursor: pointer;
} .a{
color: #25719e; }
.b{
background-attachment: fixed; }
</style> </head>
<div id="topbar"> <div id="gambar">
<img src="images/logoforumsquaretopbar.png"/> </div>
</div>
<div id="utama"> <div id="judul">
Signup Forumsquare </div>
<div id="input">
<form action="proses_registrasi.php" method="post" > <div>
<input type="text" name="nama_lengkap" id="nama_lengkap" maxlength="30" placeholder="Enter your Full Name
(Max 30)" class="update" required
oninvalid="this.setCustomValidity('Silahkan masukkan Nama Lengkap')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:10px;">
<input type="text" name="username" maxlength="20" placeholder="Enter your Username (Max 20)" class="update" required
oninvalid="this.setCustomValidity('Silahkan masukkan Username')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:10px;">
<input type="password" name="password" maxlength="50" placeholder="Enter your Password (Max 50)"
class="update" required
oninvalid="this.setCustomValidity('Silahkan masukkan Password')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:10px;">
<input type="email" name="email" maxlength="40" placeholder="Enter your Email (Max 40)" class="update" required
oninvalid="this.setCustomValidity('Silahkan masukkan Email')" oninput="setCustomValidity('')"/>
</div>
<div style="margin-top:10px;"> <th>Gender : </th>
<input type="radio" name="jenis_kelamin" value="Laki-laki" class="" required>Male
<input type="radio" name="jenis_kelamin" value="Perempuan" class="" required>Female
</div>
<td align="left" valign="top"><input name="avatar" type="hidden" value="avatar/fotodefault.jpg" /> </td>
<div style="margin-top:10px;">
<input type="submit" name="input" value="Signup" class="button" />
</div>
<div style="margin-top:10px;">
<td align="left" valign="top"><div align="center"><span class="putih">Sudah punya akun? Login <strong><a href="login.php" style="text-decoration:none"
class="a">disini</a> </strong></span></div></td> </div>
<?php
if(isset($_GET['status'])){ $status = $_GET['status']; }
else{
$status = ""; }
echo "$status"; ?>
</div> </form> </div> </div>
<div align="center" style="margin-top: 190px;"> <p class="abu_abu">Copyright © Forumsquare</p> </div>
</body> </html>
4. Proses Signup ( proses_registrasi.php )
<?php
$nama_lengkap = $_POST['nama_lengkap']; $username = $_POST['username']; $password = $_POST['password'];
$email = $_POST['email'];
$jenis_kelamin = $_POST['jenis_kelamin'];
$avatar = $_POST['avatar'];
$tanggal_daftar = date("Y/m/d"); include("config.php");
//Seleksi field2 yang kosong
if (empty($nama_lengkap) || empty($username) || empty($password) || empty($email) || empty($jenis_kelamin))
{
header("location:registrasi.php?status=*Semua field harus diisi");
} else{
//cek username yang sama
$query = mysql_fetch_array(mysql_query("SELECT username FROM tabel_member WHERE username='$username'"));
if($query){
header("location:registrasi.php?status=*Username telah digunakan");
} else{
$sql = "INSERT INTO tabel_member (nama_lengkap, username,
password, email, jenis_kelamin, tanggal_daftar, avatar ) VALUES ('$nama_lengkap', '$username', '$password', '$email'
,'$jenis_kelamin', '$tanggal_daftar', '$avatar')"; $hasil = mysql_query($sql, $koneksi);
if($hasil){
echo "<script> alert('Selamat. Anda telah terdaftar di forum ini, Silahkan login dengan username dan password anda.'); location = 'login.php'; </script>";
else {
echo "Data gagal disimpan <br>"; }
} }
?>
5. Tampilan Utama ( index.php )
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); error_reporting(E_ALL ^ E_DEPRECATED);
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
include "config.php";
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
$query2=mysql_fetch_array(mysql_query("select * from tabel_topik where pengirim='$username'"));
//Menghitung jumlah topik dan jumlah member
$query3 = mysql_query("SELECT * FROM tabel_topik"); $query4 = mysql_query("SELECT * FROM tabel_member"); $jumlah_topik = mysql_num_rows($query3);
$jumlah_member = mysql_num_rows($query4); $avatar = $query['avatar'];
//mencari total view (dilihat) ?>
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); $id_topik = $_GET['id_topik'];
$query6=mysql_fetch_array(mysql_query("select dilihat from tabel_topik where id_topik='$id_topik'"));
$dilihat = $query6 ['dilihat'] + 1;
$sql2 = "UPDATE tabel_topik SET dilihat='$dilihat' WHERE id_topik='$id_topik'";
$hasil2 = mysql_query($sql2, $koneksi); ?>
<!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>Forumsquare</title> <style type="text/css"> body{
font-family: arial; font-size: 14px;
}
#topbar{
padding: 8px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin: 0 auto; margin-top: 7%; margin-left: 240px; text-align: center; }
#tabel{
width: 0px; margin: 0 auto; margin-top: 0px; margin-left: 700px; text-align: center; }
#topbar2{
padding: 2px;
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 430px;
box-shadow: 0 0 5px #888; }
input{
padding: 10px; border: 0; }
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
background-color: #25719e; border-radius: 10px;
width: 260px; color: #fff; }
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
} .a{
color: #25719e; }
.putih {
color: #FFF; }
.tabel_thread{
font-family:arial; font-size:2;
color: #25719e; }
.thread {
color: black; font-size: 20px; left: 100px; }
.bulat2{
vertical-align: middle; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; }
.b{
background-attachment: fixed; background-size: 100%;
} a {
color:#25719e; }
</style> </head>
<body class="b" background="images/bgforum5.jpg"> <div id="topbar">
<div id="navbar"> <table>
<tr>
<td width="108"><div align="center" class="navitem"><strong><a href="index.php"><img
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
<td width="115"><div align="center" class="navitem"><strong><a href="gantipass.php"><img
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div> <div id="utama">
<div id="topbar2"> <tr>
<td bgcolor="#000000"><div align="left"> <table width="840" border="0">
<tr>
<td><div align="center"><strong>Total Thread : <?php echo $jumlah_topik ?></strong></div></td>
<td><div><strong>Total Member : <?php echo $jumlah_member ?></strong> </div></td>
height="28"/></a> <?php echo $_SESSION['username']; echo " "?></strong></div></td>
</tr> </table> </div></td> </tr>
</div>
<div id="input"> <tr>
<td><div align="left" class="thread"><font face=""><strong>All Thread</strong></font></div></td>
</tr> <tr>
<td> </td> </tr>
<tr> <?php
$id_topik = $_GET['id_topik'];
$query5=mysql_fetch_array(mysql_query("select * from tabel_topik where id_topik='$id_topik'"));
?>
<td height="86"><div align="center">
<div align="center" style="overflow:auto; width:790px; height:390px;">
<table width="775" border="0"> <tr>
<td width="62" bgcolor="#CCCCCC"><div align="center"><strong>#</strong></div></td>
<td width="253" bgcolor="#CCCCCC"><div align="center"><font face=""
size="2"><strong>Topik</strong></font></div></td> <td width="128" bgcolor="#CCCCCC"><div align="center"><font face=""
size="2"><strong>Pengirim</strong></font></div></td> <td width="59" bgcolor="#CCCCCC"><div align="center"><font face=""
size="2"><strong>Balasan</strong></font></div></td> <td width="60" bgcolor="#CCCCCC"><div align="center"><font face=""
size="2"><strong>Dilihat</strong></font></div></td> <td width="183" bgcolor="#CCCCCC"><div align="center"><font face=""
size="2"><strong>Tanggal</strong></font></div></td> </tr>
<?php $nomor = 1;
$sql = "SELECT * FROM tabel_topik ORDER by tanggal DESC"; $hasil=mysql_query($sql,$koneksi);
while($record=mysql_fetch_array($hasil)){ ?>
<tr>
<td valign="top"> <font face="" size="2"><?php echo $nomor++; ?></font></td>
<td valign="top"><img src="images/threadall.png" alt="" width="22" height="22" align="left" /> <font
face="verdana" size="2"><strong><a href="view.php?id_topik=<?php echo $record['id_topik']; ?>"><?php echo $record['topik'];
<td valign="top"><div align="center"><font face="" size="2"><strong><?php echo $record['pengirim'];
?></strong></font></div></td>
<td valign="top"><div align="center"><font face="" size="2"><?php echo $record['total_balasan']; ?></font></div></td>
<td valign="top"><div align="center"><font face="" size="2"><?php echo $record['dilihat']; ?></font></div></td>
<td valign="top"><div align="center"><font face="" size="2"><?php echo $record['tanggal']; ?></font></div></td>
</tr> <?php //Berhenti Looping }
mysql_close(); ?>
</table> </div> </div> </div></td> </tr>
</table>
<div align="center" style="margin-top: 190px;"> <p class="abu_abu">Copyright © Forumsquare</p> </div>
</body> </html>
6. Tampilan Pembuatan Thread ( create.php )
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); error_reporting(E_ALL ^ E_DEPRECATED);
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
include "config.php";
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
$query2=mysql_fetch_array(mysql_query("select * from tabel_topik where pengirim='$username'"));
//Menghitung jumlah topik dan jumlah member
$query3 = mysql_query("SELECT * FROM tabel_topik"); $query4 = mysql_query("SELECT * FROM tabel_member"); $jumlah_topik = mysql_num_rows($query3);
$jumlah_member = mysql_num_rows($query4); //mencari total view (dilihat)
?> <?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); $id_topik = $_GET['id_topik'];
$dilihat = $query6 ['dilihat'] + 1;
$sql2 = "UPDATE tabel_topik SET dilihat='$dilihat' WHERE id_topik='$id_topik'";
$hasil2 = mysql_query($sql2, $koneksi); ?>
<!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>Thread Baru</title> <style type="text/css"> body{
font-family: arial; font-size: 14px;
background-attachment: fixed; background-color: #cccccc; }
#topbar{
padding: 8px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin: 0 auto; margin-top: 7%; margin-left: 280px; text-align: center; }
#utama2{ width: 420px; margin: 0 auto; margin-top: 3%; }
#tabel{
}
#topbar2{
padding: 8px;
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#judul{
padding: 15px; text-align: center; color: #000000; font-size: 20px;
background-color: #fafafa; border-top-right-radius: 20px; border-top-left-radius: 20px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 330px;
moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
}
#input2{
background-color: #fafafa; padding: 20px;
border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; }
input{
padding: 10px; border: 0; }
.border{
border-width: 5px; border-style: solid; width: 150px;
border-color: white; float: left;
margin-left: 50px; }
.update{
width: 240px; }
.button{
width: 80px; }
.button:hover{
background-color: #cccccc; cursor: pointer;
}
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
} .a{
color: #25719e; }
.putih { color: #FFF; }
.tabel_thread{ font-family:arial; font-size:2;
color: #25719e; }
.thread { color: black; font-size: 20px; left: 100px; }
.bulat{
border-radius: 100em; }
.b{
background-attachment: fixed; background-size: 100%;
} .f{
font-family: sans-serif; }
a {
text-decoration:none; font-weight:bold; color:#25719e; }
</style> </head>
<body class="b" background="images/bgforum5.jpg"> <body>
<div id="topbar"> <div id="navbar">
<table> <tr>
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
<td width="115"><div align="center" class="navitem"><strong><a href="gantipass.php"><img
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div> <div id="utama">
<table width="800" border="0" style="border: 2px solid gray; border-radius: 10px 10px 10px 10px; background:#eaeaec;">
<tr>
<td colspan="2" bgcolor="#CCCCCC"><div
align="center"><strong><font face="" size="5">Thread Baru</font></strong></div></td>
</tr> <tr>
<td> </td> </tr>
<tr> <?php
$id_topik = $_GET['id_topik'];
$query5=mysql_fetch_array(mysql_query("select * from tabel_topik where id_topik='$id_topik'"));
?>
<td height="86"><div align="center"> <div align="center">
<form id="form1" name="form1" method="post" action="proses_create.php">
<table width="600" border="0"> <tr>
</strong></div></td> </tr>
<tr>
<td valign=""><strong>Username</strong></td> <td valign=""><div
align="center"><strong>:</strong></div></td>
<td valign=""><input name="username" type="text" id="username" value="<?php echo $username?>" readonly="readonly" /></td>
</tr> <tr>
<td width="131"
valign=""><strong>Topik</strong></td>
<td width="13" valign=""><div align="center"><strong>:</strong></div></td>
<td width="285" valign=""><strong><input
name="topik" type="text" maxlength="40" placeholder="Judul Thread" required required oninvalid="this.setCustomValidity('Silahkan masukkan judul thread')"
oninput="setCustomValidity('')"/></strong></td> </tr>
<tr>
<td valign="top"><strong>Isi</strong></td> <td valign="top"><div
align="center"><strong>:</strong></div></td> <td valign="top"><strong>
<textarea class="f" placeholder="Tulis isi topik..." name="isi" cols="65" rows="10"></textarea>
</strong></td> </tr>
<tr>
<td valign="top"> </td> <td valign="top"> </td>
<td valign="top"><input class="button" type="submit" value="Kirim" />
<input class="button" type="reset" value="Hapus" /></td>
</tr> </table>
<div align="center" style="margin-top:5px"> <?php
if(isset($_GET['status'])){ $status = $_GET['status']; }
else{
$status = ""; }
echo "$status"; ?>
<div align="center" style="margin-top:10px"> </form>
7. Proses Pembuatan Thread ( proses_create.php )
<?php
$pengirim = $_POST['username'];
$topik = $_POST['topik'];
$isi = $_POST['isi'];
$tanggal = date("Y-m-d H:i:s"); include("config.php");
if (empty($isi) || empty($topik)) {
header("location:create.php?status=*Maaf, semua field harus diisi");
} else{
$sql = "INSERT INTO tabel_topik (pengirim, topik, isi, tanggal) VALUES ('$pengirim', '$topik', '$isi', '$tanggal')";
$hasil = mysql_query($sql, $koneksi); if($hasil){
header ("location:index.php"); }
else {
echo "Thread gagal disimpan <br>"; }
} ?>
8. Tampilan Halaman Obrolan ( view.php )
<?php
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
include "config.php";
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
$query2=mysql_fetch_array(mysql_query("select * from tabel_topik where pengirim='$username'"));
//Menghitung jumlah topik dan jumlah member
$query3 = mysql_query("SELECT * FROM tabel_topik"); $query4 = mysql_query("SELECT * FROM tabel_member"); $jumlah_topik = mysql_num_rows($query3);
$jumlah_member = mysql_num_rows($query4); //mencari total view (dilihat)
$id_topik = $_GET['id_topik'];
$query6=mysql_fetch_array(mysql_query("select dilihat from tabel_topik where id_topik='$id_topik'"));
$dilihat = $query6 ['dilihat'] + 1;
$sql2 = "UPDATE tabel_topik SET dilihat='$dilihat' WHERE id_topik='$id_topik'";
<!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>View <?php
//Mengambil judul topik
$query6=mysql_fetch_array(mysql_query("select * from tabel_topik where id_topik='$id_topik'"));
echo """ .$query6['topik']. """?></title> <style type="text/css">
body{
font-family: ; font-size: ;
background-attachment: fixed; background-color: #cccccc; }
#topbar{
padding: 8px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin-top: 7%; margin-left: 240px; }
#utama2{ width: 420px; margin: 0 auto; margin-top: 3%; }
#tabel{
width: 0px; margin: 0 auto; margin-top: 0px; margin-left: 700px; text-align: center; }
#topbar2{
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#judul{
padding: 15px; text-align: center; color: #000000; font-size: 20px;
background-color: #fafafa; border-top-right-radius: 20px; border-top-left-radius: 20px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 330px;
moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
}
#input2{
background-color: #fafafa; padding: 20px;
border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; }
input{
padding: 10px; border: 0; }
.border{
border-width: 5px; border-style: solid; width: 150px;
border-color: white; float: left;
margin-left: 50px; }
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
.button:hover{
background-color: #cccccc; cursor: pointer;
}
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
} .a{
color: #25719e; }
.putih { color: #FFF; }
.tabel_thread{ font-family:arial; font-size:2;
color: #25719e; }
.thread { color: black; font-size: 20px; left: 100px; }
.bulat{
border-radius: 100em; }
a {
text-decoration:none; font-weight:bold; color:#25719e; }
.b{
background-attachment: fixed; background-size: 100%;
} .gf{
font-family: arial; font-size: 14px; color: #c2c7ce; }
.ttf{
font-family: arial; font-size: 10px; font-weight: bold; color: #c2c7ce; }
.tf{
font-family: arial; font-size: 14px; }
.f{
font-size: 16px; font-weight: bold; }
</style> </head>
<body class="b" background="images/bgforum2.jpg"> <body>
<div id="topbar"> <div id="navbar">
<table> <tr>
<td width="108"><div align="center" class="navitem"><strong><a href="index.php"><img
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
<td width="115"><div align="center" class="navitem"><strong><a href="gantipass.php"><img
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div>
<div id="utama" align="center">
<table class="tf" width="800" border="0" style="border-radius: 10px 10px 10px 10px; background:rgba(2, 2, 2, 0.5);">
<tr>
<td> </td> </tr>
<tr> <?php
$id_topik = $_GET['id_topik'];
$query5=mysql_fetch_array(mysql_query("select * from tabel_topik where id_topik='$id_topik'"));
$username = $query5['pengirim'];
$query7=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username' "));
?>
<td height="304">
<table width="100%" border="0" bgcolor="" style="background:rgba(2, 2, 2, 0.0);">
<tr>
<td width="100%" bgcolor="#CCCCCC" style="background:rgba(2, 2, 2, 0.0);"><div
class="gf"><strong><img src="images/threadall.png" alt="" width="22" height="22" align="left" />Dikirim <?php echo $query5['tanggal']; ?></strong></td></div>
<td width="100%" height="27" bgcolor="#CCCCCC" style="background:rgba(2, 2, 2, 0.0);"><div align="right" class="gf"><strong># 1</strong></div></td>
</tr> <tr>
<td colspan="2" valign="top" bgcolor="#FFFFFF" style="border-radius: 10px 10px 10px 10px;"><p><a
href="profil.php?username=<?php echo $query5['pengirim'];
?>"><strong><img class="bulat" src="<?php echo $query7['avatar']; ?>" width="50" height="50" align="left" /></a> <a
href="profil.php?username=<?php echo $query5['pengirim']; ?>"><?php echo $query5['pengirim']; ?></a><br />
<span class="merah"><font size="">Topik :</font><font size="3"></font></span><font size=""> <?php echo $query5['topik']; ?><br />
</font></strong> <strong>
</font></strong>
<pre class="f"><?php echo $query5['isi']; ?></pre></td>
</tr> <tr>
<td colspan="2" valign="top" bgcolor="#CCCCCC" style="background:rgba(2, 2, 2, 0.0);"><div align="right">
<table width="293" border="0"> <tr>
<td width="133"><div align="right"
class="gf"><strong><?php echo $query5['total_balasan']; ?> balasan </strong></div></td>
<td width="252"><div align="right" class="gf"><strong><?php echo $query5['dilihat']; ?> kali dilihat</strong></div></td>
</tr> </table> </div></td> </tr>
</table>
<div align="right"><a href="balas.php?id_topik=<?php echo $id_topik; ?>"><img src="images/reply.png" width="72" height="26" title="Balas Thread Ini" /></a><br />
</div>
<div align="right"></div>
<br /> </div> </hr> <p>
<?php
// Menampilkan komentar $nomor = 2;
$sql2="SELECT * FROM tabel_komentar WHERE id_topik='$id_topik' ORDER BY tanggal ASC";
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result2)){ ?>
</p>
<table width="100%" border="0"> <tr>
<td bgcolor="#CCCCCC" style="background:rgba(2, 2, 2, 0.0);"><table width="100%" border="0">
<tr>
<td width="27%" valign="top"> </td>
<td width="27%" valign="top"><div align="right" class="gf"><strong># <?php echo $nomor++; ?></strong></div></td>
</tr> <tr>
<td height="20" colspan="3" valign="top"
bgcolor="#FFFFFF" style="border-radius: 10px 10px 10px 10px;"><p> <?php
//Menyesuaikan gambar / avatar $user2 = $rows['penjawab']; $queryAvatar=mysql_fetch_array(mysql_query("select * from tabel_member where username='$user2'"));
?>
<a href="profil.php?username=<?php echo
$rows['penjawab']; ?>" ><strong><img class="bulat" src="<?php echo $queryAvatar['avatar']; ?>" alt="" width="50" height="50"
align="left" /></strong><?php echo $rows['penjawab']; ?></a><br /> <strong>Re : <?php echo $rows['topik'];
?></strong><br/>
<pre class="f"><?php echo $rows['isi']; ?></pre></td>
</tr> <tr>
<td width="27%" valign="top"
class="ttf"><strong>Tanggal : <?php echo $rows['tanggal']; ?></td></strong>
<td height="18" colspan="3" valign="top" bgcolor="#CCCCCC"style="background:rgba(2, 2, 2, 0.0);"></td>
</tr>
</table></td> </tr>
</table> <p>
<?php }
?> </p>
<td><div align="right"><a href="balas.php?id_topik=<?php echo $id_topik; ?>"><img src="images/reply.png" alt="" width="72" height="26" title="Balas Thread Ini"/></a></div></td>
</tr>
</table> </div></td> </tr>
</table> </div> </div> </body> </html>
9. Tampilan Balas Obrolan ( balas.php )
<?php
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
include "config.php";
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
$query2=mysql_fetch_array(mysql_query("select * from tabel_topik where pengirim='$username'"));
//Menghitung jumlah topik dan jumlah member
$query3 = mysql_query("SELECT * FROM tabel_topik"); $query4 = mysql_query("SELECT * FROM tabel_member"); $jumlah_topik = mysql_num_rows($query3);
$jumlah_member = mysql_num_rows($query4); //mencari total view (dilihat)
$id_topik = $_GET['id_topik'];
$query6=mysql_fetch_array(mysql_query("select dilihat from tabel_topik where id_topik='$id_topik'"));
$dilihat = $query6 ['dilihat'] + 1;
$sql2 = "UPDATE tabel_topik SET dilihat='$dilihat' WHERE id_topik='$id_topik'";
$hasil2 = mysql_query($sql2, $koneksi); ?>
<!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>Reply Thread</title> <style type="text/css"> body{
font-family: arial; font-size: 14px;
#topbar{
padding: 8px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin: 0 auto; margin-top: 7%; margin-left: 280px; text-align: center; }
#utama2{ width: 420px; margin: 0 auto; margin-top: 3%; }
#tabel{
width: 0px; margin: 0 auto; margin-top: 0px; margin-left: 700px; text-align: center; }
#topbar2{
padding: 8px;
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#judul{
color: #000000; font-size: 20px;
background-color: #fafafa; border-top-right-radius: 20px; border-top-left-radius: 20px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 330px;
moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
}
#input2{
background-color: #fafafa; padding: 20px;
border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; }
input{
padding: 10px; border: 0; }
.border{
border-width: 5px; border-style: solid; width: 150px;
border-color: white; float: left;
margin-left: 50px; }
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
width: 80px; }
.button:hover{
background-color: #cccccc; cursor: pointer;
}
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
} .a{
} .b{
background-attachment: fixed; background-size: 100%;
}
.putih { color: #FFF; }
.tabel_thread{ font-family:arial; font-size:2;
color: #25719e; }
.thread { color: black; font-size: 20px; left: 100px; }
.bulat{
border-radius: 100em; }
.f{
font-family: sans-serif; }
a {
text-decoration:none; font-weight:bold; color:#25719e; }
</style> </head>
<body class="b" background="images/bgforum5.jpg"> <body>
<div id="topbar"> <div id="navbar">
<table> <tr>
<td width="108"><div align="center" class="navitem"><strong><a href="index.php"><img
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div> <div id="utama">
<table width="800" border="0" style="border: 2px solid gray; border-radius: 10px 10px 10px 10px; background:#eaeaec;">
<tr>
<td colspan="2" bgcolor="#CCCCCC"><div
align="center"><strong><font face="" size="5">Reply Thread</font></strong></div></td>
</tr> <tr>
<td> </td> </tr>
<tr>
<td><div align="center"> <div align="center">
<div align="center"> <?php
//mengambil biodata yang membalas thread $id_topik = $_GET['id_topik'];
$hasil=mysql_fetch_array(mysql_query("select * from tabel_topik where id_topik='$id_topik'"));
?>
<form id="form1" name="form1" method="post" action="proses_balas.php">
<table width="378" border="0"> <tr>
<td colspan="2"><div align="center" class="merah">
</div></td> </tr> <tr>
<td><strong>Id Topik</strong></td> <td><strong>:
<input name="id_topik" type="text"
value="<?php echo $hasil['id_topik']; ?>" readonly="readonly" /> </strong></td>
</tr> <tr>
<td><strong>Topik</strong></td> <td><strong>:
<input name="topik" type="text" id="topik" value="<?php echo $hasil['topik']; ?>" readonly="readonly" />
</strong></td> </tr>
<tr>
<td><strong>:
<input name="penjawab" type="text" value="<?php echo $username; ?>" readonly="readonly" />
</strong></td> </tr>
<tr>
<td colspan="2"><textarea class="f" placeholder="Tulis komentar..." name="isi" cols="65" rows="10"></textarea></td>
</tr> <tr>
<td width="94"> </td>
<td width="278"><div align="right"> <input class="button" name="input" type="submit" value="Kirim" />
</div></td> </tr>
</table>
<div align="center" style="margin-top:5px"> <?php
if(isset($_GET['status'])){ $status = $_GET['status']; }
else{
$status = ""; }
echo "$status"; ?>
<div align="center" style="margin-top:10px"> </form>
</div> </div> </div></td> </tr>
</table> </div> </div> </body> </html>
10. Proses Balas Obrolan ( proses_balas.php )
<?php
$id_topik = $_POST['id_topik'];
$topik = $_POST['topik'];
$penjawab = $_POST['penjawab'];
$isi = $_POST['isi'];
$tanggal = date("Y-m-d H:i:s"); include("config.php");
if (empty($isi)) {
header("location:balas.php?id_topik=$id_topik&status=*Maaf, komentar tidak boleh kosong");
$sql = "INSERT INTO tabel_komentar (id_topik, topik, penjawab, isi, tanggal) VALUES ('$id_topik', '$topik', '$penjawab', '$isi', '$tanggal')";
$hasil = mysql_query($sql, $koneksi); if($hasil){
echo "
<script> location = 'view.php?id_topik=$id_topik'; </script> ";
} else {
echo "komentar gagal disimpan <br>"; }
$query_balasan = mysql_query("SELECT id_topik FROM tabel_komentar WHERE id_topik='$id_topik'");
$total_balas = mysql_num_rows($query_balasan); $total_balasan = $total_balas;
//memasukan total balasan ke database
$sql2 = "UPDATE tabel_topik SET total_balasan='$total_balasan' WHERE id_topik='$id_topik'";
$hasil2 = mysql_query($sql2, $koneksi); if($hasil2){
echo "ok"; }
else {
echo "komentar gagal disimpan <br>"; }
} ?>
11. Tampilan Upload File ( upload.php )
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); error_reporting(E_ALL ^ E_DEPRECATED);
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
?>
<!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>File/Dokumen</title> <style type="text/css"> body{
font-family: arial; font-size: 14px;
background-color: #779aaf; }
#topbar{
padding: 8px; text-align: left; color: #fff; font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin: 0 auto; margin-top: 7%; margin-left: 240px; text-align: center; }
#tabel{
width: 0px; margin: 0 auto; margin-top: 0px; margin-left: 700px; text-align: center; }
#topbar2{
padding: 2px;
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 430px;
webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
} input{
padding: 10px; border: 0; }
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
background-color: #25719e; color: #fff;
}
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
}
.button:hover{
background-color: #00598d; cursor: pointer;
} .a{
color: #25719e; }
.putih {
color: #FFF; }
.thread {
color: black; font-size: 20px; left: 100px; }
.b{
background-attachment: fixed; background-size: 100%;
}
.fontsize{
font-size: 13px; }
a {
font-weight:bold; color:#25719e; }
</style> </head> <body>
<div id="navbar"> <table>
<tr>
<td width="108"><div align="center" class="navitem"><strong><a href="index.php"><img
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
<td width="115"><div align="center" class="navitem"><strong><a href="gantipass.php"><img
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div>
<div id="utama"> <div id="input">
<div>
<a href="upload.php" class="active">Upload File</a> |
<a href="download.php">Download File</a> </div>
<div>
<h2>Upload</h2>
<p>Upload file Anda dengan melengkapi form di bawah ini. File yang bisa di Upload hanya file dengan ekstensi <b>.doc, .docx, .xls, .xlsx, .ppt, .pptx, .pdf, .rar, .zip</b> dan besar file (file size) maksimal hanya 1 MB.</p>
<div>
<form action="" method="post" enctype="multipart/form-data">
<table width="800" align="center" border="0" bgcolor="#eee" cellpadding="2" cellspacing="0">
<td width="40%" align="right" class="fontsize"><b>Username</b><b> :</b></td><td
align="left"><input align="left" name="username" type="text" id="Username" size="40" value="<?php echo $username?>"
readonly="readonly" /></td> </tr> <tr>
<td width="40%" align="right" class="fontsize"><b>Nama File</b><b> :</b></td><td
align="left"><input type="text" name="nama" size="40" required /></td>
</tr> <tr>
<td width="40%" align="right" class="fontsize"><b>Pilih File</b><b> :</b></td><td
align="left"><input align="left" type="file" name="file" required /></td>
</tr>
<div style="margin-top:10px;"> </div>
</div> </table> <tr> </tr>
<div style="margin-top:10px;">
<input class="button" type="submit" name="upload" value="Upload" /></td>
</div> </form>
<?php
ini_set("display_errors",0); include('config.php'); if($_POST['upload']){
$allowed_ext = array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'rar', 'zip');
$file_name =
$_FILES['file']['name'];
$file_ext =
strtolower(end(explode('.', $file_name)));
$file_size =
$_FILES['file']['size'];
$file_tmp =
$_FILES['file']['tmp_name'];
$nama = $_POST['nama'];
$username = $_POST['username']; $tgl = date("Y-m-d");
if(in_array($file_ext, $allowed_ext) === true){
if($file_size < 1044070){ $lokasi =
'files/'.$username.'.'.$nama.'.'.$file_ext;
move_uploaded_file($file_tmp, $lokasi);
$in = mysql_query("INSERT INTO download VALUES(NULL, '$username', '$tgl', '$nama','$file_ext', '$file_size', '$lokasi')");
echo '<div class="ok">SUCCESS: File berhasil di Upload!</div>';
}else{
echo '<div class="error">ERROR: Gagal upload file!</div>';
} }else{
echo '<div
class="error">ERROR: Besar ukuran file (file size) maksimal 1 Mb!</div>';
} }else{
echo '<div class="error">ERROR: Ekstensi file tidak di izinkan!</div>';
} }
?> </p> </div> </div> </body> </html>
12. Tampilan Download File ( download.php )
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); error_reporting(E_ALL ^ E_DEPRECATED);
session_start();
if(!isset($_SESSION['username'])){ header("location:login.php"); exit();
}
if(isset($_SESSION['username'])){
$username = $_SESSION['username']; }
$query=mysql_fetch_array(mysql_query("select * from tabel_member where username='$username'"));
?>
<!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>File/Dokumen</title> <style type="text/css"> body{
font-family: arial; font-size: 14px;
background-attachment: fixed; background-color: #779aaf; }
#topbar{
font-size: 20px;
background-color: #25719e;
border-bottom: 1px solid #00598d; position: fixed;
top: 0; left: 0; right: 0; }
#navbar{
width: 550px; height: 8px; border: 0px; float: right;
padding-right: 30px; }
#gambar{
padding-left: 50px; }
#utama{
width: 900px; margin: 0 auto; margin-top: 7%; margin-left: 240px; text-align: center; }
#tabel{
width: 0px; margin: 0 auto; margin-top: 0px; margin-left: 700px; text-align: center; }
#topbar2{
padding: 2px;
text-align: center; color: #000000; font-size: 13px;
background-color: #25719e; border-top-right-radius: 10px; border-top-left-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
margin-bottom: 30px; }
#input{
background-color: #ffffff; padding: 30px;
text-align: center; height: 430px;
moz-box-shadow: 0 0 5px #888; webkit-box-shadow: 0 0 5px#888; box-shadow: 0 0 5px #888;
} input{
}
.update{
width: 240px; }
.deskripsi{ height: 50px; width: 255px; }
.button{
background-color: #25719e; color: #fff;
}
.navitem{
display: inline-block; width: 70px;
height: 35px; padding-top: 10px; }
.navitem:hover{
background-color: #25719e; cursor: pointer;
}
.button:hover{
background-color: #00598d; cursor: pointer;
} .a{
color: #25719e; }
.putih {
color: #FFF; }
.thread {
color: black; font-size: 20px; left: 100px; }
.b{
background-attachment: fixed; background-size: 100%;
}
.fontsize{
font-size: 13px; }
a {
font-weight:bold ; color:#25719e; }
</style> </head> <body>
<body class="b" background="images/bgforum5.jpg"> <div id="topbar">
<div id="navbar"> <table>
<tr>
src="images/homeforum.png" width="25" height="25" title="Home" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="upload.php"><img src="images/fileforum3.png" width="25" height="25" title="File/Dokumen" /></a><br /></strong></div></td>
<td width="108"><div align="center" class="navitem"><strong><a href="create.php"><img
src="images/threadbaruforum.png" width="25" height="25" title="Buat Thread Baru" /></a><br /></strong></div></td>
<td width="110"><div align="center"
class="navitem"><strong><a href="profil.php?username=<?php echo $username ?>"><img src="images/profilforum.png" width="25" height="25" title="Profil"/></a><br /></strong></div></td>
<td width="123"><div align="center" class="navitem"><strong><a href="members.php"><img src="images/memberlainforum.png" width="25" height="25" title="Lihat Daftar Member"/></a><br /></strong></div></td>
<td width="115"><div align="center" class="navitem"><strong><a href="gantipass.php"><img
src="images/gantipasswordforum.png" width="25" height="25" title="Ganti Password" /></a><br /></strong></div></td>
<td width="104"><div align="center" class="navitem"><strong><a href="logout.php"><img
src="images/logoutforum.png" width="25" height="25" title="Keluar" /></a><br /></strong></div></td>
</tr> </table> </div>
<div id="gambar">
<a href="index.php"><img
src="images/logoforumsquaretopbar.png"/></a> </div>
</div>
<div id="utama"> <div id="input">
<div>
<a href="upload.php">Upload File</a> |
<a href="download.php" class="active">Download File</a>
</div>
<div id="content"> <h2>Download</h2>
<p>Silahkan download file yang sudah di Upload di website ini. Untuk men-Download Anda bisa mengklik Judul file yang di inginkan.</p>
<p>
<table width="800" align="center" border="0" bgcolor="#eee" cellpadding="2" cellspacing="1">
<tr class="fontsize"> <th width="30">No.</th>
<th width="80">Tgl. Upload</th> <th width="270">Nama File</th> <th>Pengirim</th>
<th width="70">Tipe</th> <th width="70">Ukuran</th> </tr>