Listing Program Menu Index - PHP

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

1. Listing Program Menu index.

php

<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8" />
<title>IPCAM</title>
<link href="stylesheets/screen.css" rel="stylesheet" media="screen,projection" />
<style>
.forms li {
position: relative;
}
.show-password-link {
display: block;
position: absolute;
z-index: 11;
}
.password-showing {
position: absolute;
z-index: 10;
}
</style>
</head>

<body background="images/2128151154_c51d15e742_o.jpg" >


<form action="login_action.php" method="post">
<ol class="forms">
<li>
<label for="username">Username</label>
<input type="text" name="username" id="username" />
</li>
<li>
<label for="password">Password</label>
<input type="password" name="password" id="password" class="password" />
</li>
<li>
<input type="hidden" name="id_role" id="id_role"/>
</li>
<li class="buttons">
<button type="submit">Login</button>
</li>
</ol>
</form>
<!-- <script src="scripts/jquery.js"></script> -->
<!-- <script src="scripts/jquery.showPassword.js"></script> -->
<script>
$(document).ready(function() {
$(':password').showPassword({
linkRightOffset: 5,
linkTopOffset: 11
});
});
</script>
</body>
</html>

2. Listing Program login_action.php


<?php
session_start();

function redirect($link){
echo "<script>window.location='$link';</script>";
}

$username = $_POST['username'];
$password = $_POST['password'];
$id_role = $_POST['id_role'];

include("config.php");

$query= "SELECT * FROM pengguna WHERE username= '$username'";


$hasil= mysql_query($query) or die ("error");
$data= mysql_fetch_array($hasil);

//cek kesesuaian password dari form login

if ($password == $data['password'])
{

// menyimpan username dan level ke dalam session


$_SESSION['id_role'] = $data['id_role'];
$_SESSION['username'] = $data['username'];
$_SESSION['nama'] = $data['nama'];
redirect("home.php");
}

else {
//warning untuk proses login jika salah
echo "<script type='text/javascript'>alert('Cek Username dan Password
!');document.location='index.php'</script>";

?>

3. Listing Program Menu header.php


<?php
if(!isset($_SESSION))
{
session_start();
}
include "config.php";
include "cek.php";

$id_role = $_SESSION['id_role'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Video Pembelajaran Jarak Jauh</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="images/Refresh.css" type="text/css" />
<script type="text/javascript" src="flowplayer-3.2.4.min.js">

flowplayer("player", "flowplayer-3.2.4.swf");</script>

<script language="JavaScript" type="text/javascript">


function reload() {setTimeout('reloadImg("refresh")',1000)}; // 1000 = 1 second. I'd suggest a
reasonable minumum of 350
function reloadImg(id)
{
var obj = document.getElementById(id);
var rand = Math.random();
obj.src = "telkom-hotspot.no-ip.biz:5000/snapshot.cgi?user=guest&pwd=&t="+rand;
}
</script>
</head>
<body background="images/logo-polinema-final-2011.jpg">
<div id="wrap">
<div id="header">
<img src="images/header.jpg" height="160 px" width="1150 px" />
<!--h1 id="logo-text"><img src="images/LOGO.png" height="75 px" width="75 px" /><font
size="+3">Program Studi Teknik Telekomunikasi</font></span></h1-->

<form class="search" method="post" action="http://all-free-download.com/free-website-


templates/">

</form>
</div>

<div id="content-wrap">
<div id="sidebar">
<h1>Sidebar Menu</h1>
<div class="left-box">
<ul class="sidemenu">
<li><a href="home.php">Home</a></li>
<li><a href="live.php">Live Streaming</a></li>
<li><a href="video.php">Video Pembelajaran</a></li>
<li><a href="materi.php">Materi</a></li>

<?php if($id_role == 0) { ?>


<li><a href="register.php">Register</a></li>
<?php } ?>
<li><a href="logout.php">Log Out</a></li>
</ul>
</div>

</div>
<div id="main"> <a name="TemplateInfo"></a>

4. Listing Program Menu home.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php";

$nama = $_SESSION['nama'];
$username = $_SESSION['username'];
$sql = mysql_query("select * from pengguna where username='$username'");

$user_login = mysql_fetch_array($sql);
$user = $user_login['nama'];
?>

<h1>Home</h1>
<h2>Selamat Datang <?php echo $user; ?></h2>

<p><font color="#000000" size="+1"><strong><center> SELAMAT DATANG DI


SISTEM PEMBELAJARAN</center> </strong></font><font color="#0000FF"
size="+1"><strong><center> JARAK JAUH TEKNIK TELEKOMUNIKASI
</center></strong></font> </p>
<blockquote>
<p> Sistem pembelajaran jarak jauh ini diperuntukan bagi mahasiswa Teknik
Telekomunikasi yang berhalangan hadir. Untuk mempermudahkan pengaksesan sistem ini, maka
dianjurkan kepada para user atau mahasiswa yang tidak hadir menggunakan web browser
<em><strong>INTERNET EXPLORER</strong></em> agar dapat melakukan komunikasi
dengan para pengajar yang berada pada pada ruangan. </p>
</div>
</div>
<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>

5. Listing Program Untuk menu video.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php";

$id_role = $_SESSION['id_role'];

?>

<h1>Video</h1>
<?php if($id_role == 0 || $id_role == 1) { ?>
<form action="video_action.php" method="post" enctype="multipart/form-data">
<label>Nama Materi</label><select name="id_materi"><option>--Nama Materi--</option>
<?php
$querykf = "SELECT * from materi";

$resultkf=mysql_query($querykf);

while ($datakf = mysql_fetch_array($resultkf))


{
?>
<option value="<?php echo $datakf['id_materi']; ?>"><?php echo $datakf['nama_materi']; ?>
</option>
<?php } ?>
</select>

<label>Upload video</label><input type="file" name="file" size="50" />


<br />
<input type="hidden" name="aksi" value="simpan"/>
<input type="submit" name="btn_simpan" value="Save"/>
<input type="reset" value="Reset"/>
</form>
<?php } ?>
<?php include "video_view.php"; ?>
</div>
</div>

<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>

6. Listing Program video_action.php


<?php
session_start(); ?>

<?php
include "config.php";
function redirect($link){
echo "<script>window.location='$link';</script>";
}

$aksi = $_REQUEST['aksi'];
if($aksi == "simpan")
{
simpan();
}
else if($aksi == "update")
{
update();
}
else if ($aksi == "delete")
{
delete();
}

function simpan()
{

$id_materi= $_POST['id_materi'];

$file = $_FILES['file']['name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];

$move = move_uploaded_file($_FILES['file']['tmp_name'], 'file/'.$file);


$query = "INSERT INTO video(id_materi, file, video) values('$id_materi', '$file', 'file/$file')";

$result = mysql_query($query);
if($result == true)
{
redirect("video.php");}
else
{
echo "Simpan gagal<br><a href='video.php'>Lihat Data</a>".$query;
}
}

mysql_close();
?>
7. Listing Program video_detail.php
<?php
session_start();

include "header.php";
include "cek.php";
?>

<h1>Video Materi</h1>
<?php
$id_video = $_GET['id_video'];
$cServerAddress = $_SERVER['PHP_SELF'] ;
$sql = mysql_query("select m.*, v.* from materi m, video v where id_video = '$id_video' and
m.id_materi = v.id_materi");
while ($data = mysql_fetch_array($sql))

{
?>

<div id="container2" style="z-index:1;"></div>


<script type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">
var s1 = new SWFObject("./video/player.swf","ply","380","320","9","#ffffff");
s1.addParam("flashvars","file=<?php echo "http://" . $_SERVER['SERVER_NAME']
."/file/" . $data['file']; ?>&image=./video/preview.jpg");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.write("container2");
</script>

<iframe src="<?=$data['ppt']?>.ppt&embedded=true" style="width:600px; height:500px;"


frameborder="0"></iframe>
<?php } ?>

</div>
</div>

<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>

8. Listing Program video_view.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "cek.php";
?>

<?php

$sql = mysql_query("select v.*, m.* from video v, materi m where v.id_materi = m.id_materi");
while ($data = mysql_fetch_array($sql))

{
?>
<ul>
<li><a
href="video_detail.php?id_video=<?php echo $data[0]; ?>"><?php echo $data['nama_materi'];
?></a></li>
</ul>

<?php } ?>

9. Listing Program Untuk live.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php"; ?>
<script language="javascript" type="text/javascript">
alert("Untuk Mengakses Menu Live Streaming Kami Menyarankan Untuk Menggunakan
Web Browser <em>INTERNET EXPLORER</em>");
</script>
<h1>Live Streaming</h1><br />
<tabel>
<tr>
<td><form action="ruang1-1.php">
<input type="submit" name="button" id="button" value="R1.1" /></form>
<form action="ruang1-2.php">
<input type="submit" name="button" id="button" value="R1.2" /></form>
</td>
</tr>
</tabel>

</div>
</div>
<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>

10. Listing Program ruang1-1.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php"; ?>
<h1>Ruang 1.1</h1><br />
<tabel>
<td>
<tr>
<iframe src="http://telkom-hotspot.no-ip.biz:5000/index.htm" style="width:600px;
height:500px;" frameborder="0"></iframe>
</td>
</tabel>

</div>
</div>
<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>
11. Listing Program ruang1-2.php
<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php"; ?>
<h1>Ruang 1.1</h1><br />
<tabel>
<td>
<tr>
<iframe src="http://telkom-hotspot.no-ip.biz:4000/index.htm" style="width:600px;
height:500px;" frameborder="0"></iframe>
</td>
</tabel>

</div>
</div>
<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>

12. Listing Program materi.php


<?php
if(!isset($_SESSION))
{
session_start();
}

include "header.php";
include "cek.php";

$id_role = $_SESSION['id_role'];

?>

<h1>Materi</h1>
<?php if($id_role == 0 || $id_role == 1) { ?>
<form action="materi_action.php" method="post" enctype="multipart/form-data">
<label>Nama Materi</label><input type="text" name="nama_materi" size="50" />
<label>Link PPT</label><input type="text" name="ppt" size="50" />
<br />
<input type="hidden" name="aksi" value="simpan"/>
<input type="submit" name="btn_simpan" value="Save"/>
<input type="reset" value="Reset"/>
</form>
<?php } ?>
<?php include "materi_view.php"; ?>
</div>
</div>

<div id="footer">
<p> &copy; 2013 <strong>Politeknik Negeri Malang</strong> | Design by: Triaz dan Firdyan
</p>
</div>
</div>
</body>
</html>
13. Listing Program materi_action.php
<?php
session_start(); ?>

<?php
include "config.php";
function redirect($link){
echo "<script>window.location='$link';</script>";
}

$aksi = $_REQUEST['aksi'];
if($aksi == "simpan")
{
simpan();
}
else if($aksi == "update")
{
update();
}
else if ($aksi == "delete")
{
delete();
}

function simpan()
{

$nama_materi= $_POST['nama_materi'];
$ppt = $_POST['ppt'];

$query = "INSERT INTO materi(nama_materi, ppt) values('$nama_materi', '$ppt')";

$result = mysql_query($query);
if($result == true)
{
redirect("materi.php");}
else
{
echo "Simpan gagal Lihat Data</a>".$query;
}
}
function update()
{
$kf_kode = $_POST['kf_kode'];
$kode = $_POST['kode'];
$nama = $_POST['nama'];
$bentuk = $_POST['bentuk'];
$harga = $_POST['harga'];

$name = $_FILES['gambar']['name'];
$fileSize = $_FILES['gambar']['size'];
$fileError = $_FILES['gambar']['error'];

$move = move_uploaded_file($_FILES['gambar']['tmp_name'],
'C:/xampp/htdocs/flanelku/gambar/'.$name);

if($name == ""){
$query = "UPDATE flanel SET nama='$nama', bentuk='$bentuk', harga=$harga,
kf_kode='$kf_kode' WHERE kode='$kode'";
}else{

$query = "UPDATE flanel SET nama='$nama', bentuk='$bentuk', harga=$harga,


kf_kode='$kf_kode', nama_image='$name', image='gambar/$name' WHERE kode='$kode'";
}

$result = mysql_query($query);
if($result == true)
{
echo "Update sukses <br><a href='../flanelku_admin.php'>Lihat Data</a>";
}
else
{
echo "Update gagal<br><a href='../flanelku_admin.php'>Lihat Data</a>".$query;
}
}

function delete()
{
$kode = $_GET['kode'];
$query="DELETE FROM flanel WHERE kode='$kode'";
$result=mysql_query($query);
if($result == true)
{
echo "Delete sukses <br><a href='../flanelku_admin.php'>Lihat Data</a>";
}
else
{
echo "Delete gagal<br><a href='../flanelku_admin.php'>Lihat Data</a><br>$query";
}
}

mysql_close();
?>

14. Listing Program materi_view.php


<?php
session_start(); ?>

<?php
include "config.php";
function redirect($link){
echo "<script>window.location='$link';</script>";
}

$aksi = $_REQUEST['aksi'];
if($aksi == "simpan")
{
simpan();
}
else if($aksi == "update")
{
update();
}
else if ($aksi == "delete")
{
delete();
}

function simpan()
{

$nama_materi= $_POST['nama_materi'];
$ppt = $_POST['ppt'];

$query = "INSERT INTO materi(nama_materi, ppt) values('$nama_materi', '$ppt')";

$result = mysql_query($query);
if($result == true)
{
redirect("materi.php");}
else
{
echo "Simpan gagal Lihat Data</a>".$query;
}
}

mysql_close();
?>

15. Listing Program register.php


<?php
if(!isset($_SESSION))
{
session_start();
}
include "config.php";
include "cek.php";

$id_role = $_SESSION['id_role'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Video Pembelajaran Jarak Jauh</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="images/Refresh.css" type="text/css" />
<script type="text/javascript" src="flowplayer-3.2.4.min.js">

flowplayer("player", "flowplayer-3.2.4.swf");</script>

<script language="JavaScript" type="text/javascript">


function reload() {setTimeout('reloadImg("refresh")',1000)}; // 1000 = 1 second. I'd suggest a
reasonable minumum of 350
function reloadImg(id)
{
var obj = document.getElementById(id);
var rand = Math.random();
obj.src = "telkom-hotspot.no-ip.biz:5000/snapshot.cgi?user=guest&pwd=&t="+rand;
}
</script>
</head>
<body background="images/logo-polinema-final-2011.jpg">
<div id="wrap">
<div id="header">
<img src="images/header.jpg" height="160 px" width="1150 px" />
<!--h1 id="logo-text"><img src="images/LOGO.png" height="75 px" width="75 px" /><font
size="+3">Program Studi Teknik Telekomunikasi</font></span></h1-->

<form class="search" method="post" action="http://all-free-download.com/free-website-


templates/">

</form>
</div>

<div id="content-wrap">
<div id="sidebar">
<h1>Sidebar Menu</h1>
<div class="left-box">
<ul class="sidemenu">
<li><a href="home.php">Home</a></li>
<li><a href="live.php">Live Streaming</a></li>
<li><a href="video.php">Video Pembelajaran</a></li>
<li><a href="materi.php">Materi</a></li>

<?php if($id_role == 0) { ?>


<li><a href="register.php">Register</a></li>
<?php } ?>
<li><a href="logout.php">Log Out</a></li>
</ul>
</div>

</div>
<div id="main"> <a name="TemplateInfo"></a>

16. Listing Program register_action.php


<?php
session_start(); ?>

<?php
include "config.php";
function redirect($link){
echo "<script>window.location='$link';</script>";
}

$aksi = $_REQUEST['aksi'];
if($aksi == "simpan")
{
simpan();
}
else if($aksi == "update")
{
update();
}
else if ($aksi == "delete")
{
delete();
}

function simpan()
{

$nama= $_POST['nama'];
$username = $_POST['username'];
$password= $_POST['password'];
$id_role = $_POST['id_role'];

$query = "INSERT INTO pengguna(nama, username, password, id_role) values('$nama',


'$username', '$password', '$id_role')";

$result = mysql_query($query);
if($result == true)
{
redirect("register.php");}
else
{
echo "Simpan gagal<br><a href='../flanelku_admin.php'>Lihat Data</a>".$query;
}
}

function update()
{
$kf_kode = $_POST['kf_kode'];
$kode = $_POST['kode'];
$nama = $_POST['nama'];
$bentuk = $_POST['bentuk'];
$harga = $_POST['harga'];

$name = $_FILES['gambar']['name'];
$fileSize = $_FILES['gambar']['size'];
$fileError = $_FILES['gambar']['error'];

$move = move_uploaded_file($_FILES['gambar']['tmp_name'],
'C:/xampp/htdocs/flanelku/gambar/'.$name);

if($name == ""){
$query = "UPDATE flanel SET nama='$nama', bentuk='$bentuk', harga=$harga,
kf_kode='$kf_kode' WHERE kode='$kode'";
}else{

$query = "UPDATE flanel SET nama='$nama', bentuk='$bentuk', harga=$harga,


kf_kode='$kf_kode', nama_image='$name', image='gambar/$name' WHERE kode='$kode'";
}

$result = mysql_query($query);
if($result == true)
{
echo "Update sukses <br><a href='../flanelku_admin.php'>Lihat Data</a>";
}
else
{
echo "Update gagal<br><a href='../flanelku_admin.php'>Lihat Data</a>".$query;
}
}

function delete()
{
$kode = $_GET['kode'];
$query="DELETE FROM flanel WHERE kode='$kode'";
$result=mysql_query($query);
if($result == true)
{
echo "Delete sukses <br><a href='../flanelku_admin.php'>Lihat Data</a>";
}
else
{
echo "Delete gagal<br><a href='../flanelku_admin.php'>Lihat Data</a><br>$query";
}
}

mysql_close();
?>

17. Listing Program config.php


<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "ipcam";

$conn = mysql_connect($host, $user, $pass);


mysql_select_db($db);

if ($conn == false)
{
echo "Koneksi ke server gagal.";
die();
}
?>

18. Listing Pro gram cek.php


<?php
if(!isset($_SESSION))
{
session_start();
}

//jika session username belum dibuat, atau session username kosong


if (!isset($_SESSION['username'])) {
//redirect ke halaman login
echo "<script type='text/javascript'>alert('Belum
Login');document.location='index.php'</script>";
} else {
(!isset($_SESSION['nama']) || empty($_SESSION['nama']));
}
?>

19. Listing Program logout.php


<?php
session_start();
session_destroy();
header('location:index.php');
?>

You might also like