Home
<?php
include "koneksi.php";
$berita = mysql_query("SELECT * FROM berita");
while($row = mysql_fetch_object($berita)):
echo "<h1>".$row->judul."</h1>";
echo "<small>".$row->tanggal."</small>";
echo "<p>".$row->isi."</p><br>";
echo "<hr>";
$komentar = mysql_query("SELECT * FROM komentar where id_berita = ".$row->id_berita);
while($komen = mysql_fetch_object($komentar)):
echo $komen->nama." : ";
echo "<i>".$komen->komentar."</i><br><br>";
endwhile;
echo "<br>";
?>
<form method="POST" action="post_komentar.php">
<input type="hidden" name="id_berita" value="<?php echo $row->id_berita?>">
nama : <input type="text" name="nama"></input><br>
email : <input type="email" name="email"></input><br>
url : <input type="text" name="url"></input><br>
komentar : <textarea name="komentar"></textarea><br>
<input type="submit" value="kirim"><br>
</form>
<?php
endwhile;
?>
Post_komntar
<?php
include "koneksi.php";
if(isset($_POST['komentar'])&& isset($_POST['email']) && isset($_POST['nama'])):
$send = mysql_query("INSERT INTO KOMENTAR (`nama`,`email`,`url`,`komentar`,`id_berita`) VALUES ('$_POST[nama]','$_POST[email]','$_POST[url]','$_POST[komentar]','$_POST[id_berita]')");
if($send):
echo '<script>location.href="home.php";</script>';
else :
echo '<script>alert("gagal");location.href="home.php";</script>';
endif;
endif;
?>
KOneksi
<?php
mysql_connect("localhost","root","") or die("gagal koneksi");
mysql_select_db("prak9pwd");
?>
Form Index
<form action="simpan.php" method="post">
<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Simpan"></td>
</tr>
</table>
</form>
Hapus Berita
<?php
session_start();
include"koneksi.php";
if(isset($_GET['id_berita'])):
$status = mysql_query("delete from berita where id_berita=".$_GET['id_berita']);
if($status): echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';endif;
endif;
?>
Edit Berita
<?php
session_start();
include"koneksi.php";
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login dulu");location.href="login.php";</script>';
if(isset($_POST['id_berita']) && isset($_POST['judul']) && isset($_POST['isi'])):
$status = mysql_query("update berita set `judul`='$_POST[judul]',`isi`='$_POST[isi]' where id_berita=$_POST[id_berita]");
if($status):echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';
endif;
endif;
if(isset($_GET['id_berita'])):
$result = mysql_query("select * from berita where id_berita=".$_GET['id_berita']);
$berita = mysql_fetch_object($result);
?>
<form method="post" action="edit_berita.php">
<input type="hidden" name="id_berita" value="<?php echo $berita->id_berita;?>">
<label>Judul</label><input type="text" name="judul" value="<?php echo $berita->judul;?>"><br>
<label>Konten</label><textarea name="isi"><?php echo $berita->isi;?></textarea><br>
<input type="submit" value="Simpan">
</form>
<?php endif; ?>
DElete
<?php
include("koneksi.php");
$id=$_GET[id];
$query="delete from admin where id_user='$id'";
$exe=mysql_query($query);
if ($exe){
echo "<script>alert('Data Berhasil Dihapus')
location.replace('user.php')</script>";
}else{
echo "<script>alert('Data Gagal Dihapus')
location.replace('user.php')</script>";
}
?>
Admin
<?php
session_start();
if(!$_SESSION['login_status']) echo '<script>alert("anda harus login"); location.href="login.php";</script>';
include 'user.php';
?>
User
<form method="post" action="logout.php">
<input type="submit" value="Log out">
</form>
<?php
include "koneksi.php";
$sql=mysql_query("select *from admin");
echo "<table border='1'>
<tr>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Keterangan</th>
</tr>";
while($row = mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td><a href='delete.php?id=" . $row['id_user'] ."'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
?>
<a href="index.php">Tambah lagi</a><br>
Simpan
<?php
include "koneksi.php";
$input = $_POST[password];
$password = md5($input);
$sql="INSERT INTO admin (username, password, email)
VALUES
('$_POST[username]','$password','$_POST[email]')";
mysql_query($sql);
header( 'Location: user.php' );
?>
ProsesLogin
<?php
include 'koneksi.php';
session_start();
if(isset($_POST['username'])&& isset($_POST['password'])):
$query_count = mysql_query("select count(*) as jumlah from admin where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result_count = mysql_fetch_object($query_count);
if($result_count->jumlah>0):
$query = mysql_query("select * from admin where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result = mysql_fetch_object($query);
$_SESSION['id_user'] = $result->id_user;
$_SESSION['login_status'] = true;
echo '<script>alert("sukses tos sok"); location.href="admin.php";</script>';
else:
echo '<script>alert("Username dan password yang anda masukan salah"); location.href="login.php";</script>';
endif;
else:
echo '<script>alert("Username dan Password harus di isi"); location.href="login.php";</script>';
endif;
?>
Logout
<?php
session_start();
unset($_SESSION['login_status']);
echo '<script>alert("anda sudah logout"); location.href="login.php";</script>';
?>
Login
<?php
session_start();
if($_SESSION['login_status']) echo '<script>alert("anda harus login terlebih dahulu"); location.href="admin.php";</script>';
?>
<form method="post" action="proseslogin.php">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br>
<input type="submit" value="log in">
</form>
List_berita
<?php
session_start();
include "koneksi.php";
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login dulu");location.href="login.php";</script>';
if(isset($_POST['judul']) && isset($_POST['isi'])):
$date = date('Y-m-d');
$status = mysql_query("insert into berita(`judul`,`isi`,`tanggal`) values('$_POST[judul]','$_POST[isi]','".$date."')");
if($status):echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';
endif;
endif;
?>
<?php if(isset($_GET['action']) && $_GET['action']=='tambah') :?>
<form method="post" action="list_berita.php">
<label>Judul</label> <input type="text" name="judul"><br>
<label>Konten</label> <textarea name="isi"></textarea><br>
<input type="submit" value="Submit">
</form>
<?php else : ?>
<a href="?action=tambah">Tambah Berita</a>
<table>
<tr>
<td>No</td>
<td>Judul</td>
<td>Isi</td>
<td>aksi</td>
</tr>
<?php $i=1; ?>
<?php $result = mysql_query("select * from berita"); ?>
<?php while($row = mysql_fetch_object($result)): ?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row->judul; ?></td>
<td><?php echo $row->isi; ?></td>
<td>
<a href="hapus_berita.php?id_berita= <?php echo $row->id_berita ?>" onClick="return confirm('ciyus??')">Hapus</a>
<a href="edit_berita.php?id_berita= <?php echo $row->id_berita ?>">Edit</a>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
SQL
http://www.4shared.com/zip/bqrks200/prak9pwdsql.html
Home Bostr
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a class="brand" href="#">Responsi Web Dinamis</a>
<ul class="nav">
<li class="active"><a href="#">Berita</a></li>
<li><a href="list_berita.php">Dasbor</a></li>
<li><a href="login.php">Login</a></li>
</ul>
</div>
</div>
<br><br><br>
<div class="hero-unit">
<table width"500"><tr><td>
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item"><img src="img/........." align="center" width="600" height="50"></div>
<div class="item"><img src="img/......." align="center" width="600" height="50"></div>
<div class="item"><img src="img/......." align="center" width="600" height="50"></div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</td>
<td>
<table align="center" width="400"><tr><td>
<address>
<strong>Yogyakarta, Ina.</strong><br>
UNIVERSITAS AHMAD DAHLAN<br>
Jln, Supomo<br>
<abbr title="Phone">P:</abbr> 085363050136
</address>
<address>
<strong>Catur Prasongko (10018032)</strong><br>
<a href="mailto:#">caturprasongko@yahoo.co.id</a>
</address>
</td></tr></table>
</td>
</tr></table>
</div>
<table align="center" width="900"><tr><td>
<?php
include "koneksi.php";
$berita = mysql_query("SELECT * FROM berita");
while($row = mysql_fetch_object($berita)):
echo "<h1>".$row->judul."</h1>";
echo "<small>".$row->tanggal."</small>";
echo "<p>".$row->isi."</p><br>";
echo "<hr>";
$komentar = mysql_query("SELECT * FROM komentar where id_berita = ".$row->id_berita);
while($komen = mysql_fetch_object($komentar)):
echo $komen->nama." : ";
echo "<i>".$komen->komentar."</i><br><br>";
endwhile;
echo "<br>";
?>
<form method="POST" action="post_komentar.php">
<input type="hidden" name="id_berita" value="<?php echo $row->id_berita?>">
<table><tr><td>
nama </td><td><input type="text" name="nama"></input><br></td></tr>
<tr><td> email </td><td><input type="email" name="email"></input><br></td></tr>
<tr><td>url </td><td><input type="text" name="url"></input><br></td></tr>
<tr><td> komentar </td><td><textarea name="komentar"></textarea><br></td></tr>
<tr><td> </td><td><input type="submit" value="kirim"><br></td></tr></table>
</form>
<?php
endwhile;
?>
</td></tr></table>
</body>
</html>
<?php
include "koneksi.php";
$berita = mysql_query("SELECT * FROM berita");
while($row = mysql_fetch_object($berita)):
echo "<h1>".$row->judul."</h1>";
echo "<small>".$row->tanggal."</small>";
echo "<p>".$row->isi."</p><br>";
echo "<hr>";
$komentar = mysql_query("SELECT * FROM komentar where id_berita = ".$row->id_berita);
while($komen = mysql_fetch_object($komentar)):
echo $komen->nama." : ";
echo "<i>".$komen->komentar."</i><br><br>";
endwhile;
echo "<br>";
?>
<form method="POST" action="post_komentar.php">
<input type="hidden" name="id_berita" value="<?php echo $row->id_berita?>">
nama : <input type="text" name="nama"></input><br>
email : <input type="email" name="email"></input><br>
url : <input type="text" name="url"></input><br>
komentar : <textarea name="komentar"></textarea><br>
<input type="submit" value="kirim"><br>
</form>
<?php
endwhile;
?>
Post_komntar
<?php
include "koneksi.php";
if(isset($_POST['komentar'])&& isset($_POST['email']) && isset($_POST['nama'])):
$send = mysql_query("INSERT INTO KOMENTAR (`nama`,`email`,`url`,`komentar`,`id_berita`) VALUES ('$_POST[nama]','$_POST[email]','$_POST[url]','$_POST[komentar]','$_POST[id_berita]')");
if($send):
echo '<script>location.href="home.php";</script>';
else :
echo '<script>alert("gagal");location.href="home.php";</script>';
endif;
endif;
?>
KOneksi
<?php
mysql_connect("localhost","root","") or die("gagal koneksi");
mysql_select_db("prak9pwd");
?>
Form Index
<form action="simpan.php" method="post">
<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Simpan"></td>
</tr>
</table>
</form>
Hapus Berita
<?php
session_start();
include"koneksi.php";
if(isset($_GET['id_berita'])):
$status = mysql_query("delete from berita where id_berita=".$_GET['id_berita']);
if($status): echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';endif;
endif;
?>
Edit Berita
<?php
session_start();
include"koneksi.php";
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login dulu");location.href="login.php";</script>';
if(isset($_POST['id_berita']) && isset($_POST['judul']) && isset($_POST['isi'])):
$status = mysql_query("update berita set `judul`='$_POST[judul]',`isi`='$_POST[isi]' where id_berita=$_POST[id_berita]");
if($status):echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';
endif;
endif;
if(isset($_GET['id_berita'])):
$result = mysql_query("select * from berita where id_berita=".$_GET['id_berita']);
$berita = mysql_fetch_object($result);
?>
<form method="post" action="edit_berita.php">
<input type="hidden" name="id_berita" value="<?php echo $berita->id_berita;?>">
<label>Judul</label><input type="text" name="judul" value="<?php echo $berita->judul;?>"><br>
<label>Konten</label><textarea name="isi"><?php echo $berita->isi;?></textarea><br>
<input type="submit" value="Simpan">
</form>
<?php endif; ?>
DElete
<?php
include("koneksi.php");
$id=$_GET[id];
$query="delete from admin where id_user='$id'";
$exe=mysql_query($query);
if ($exe){
echo "<script>alert('Data Berhasil Dihapus')
location.replace('user.php')</script>";
}else{
echo "<script>alert('Data Gagal Dihapus')
location.replace('user.php')</script>";
}
?>
Admin
<?php
session_start();
if(!$_SESSION['login_status']) echo '<script>alert("anda harus login"); location.href="login.php";</script>';
include 'user.php';
?>
User
<form method="post" action="logout.php">
<input type="submit" value="Log out">
</form>
<?php
include "koneksi.php";
$sql=mysql_query("select *from admin");
echo "<table border='1'>
<tr>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Keterangan</th>
</tr>";
while($row = mysql_fetch_array($sql))
{
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td><a href='delete.php?id=" . $row['id_user'] ."'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
?>
<a href="index.php">Tambah lagi</a><br>
Simpan
<?php
include "koneksi.php";
$input = $_POST[password];
$password = md5($input);
$sql="INSERT INTO admin (username, password, email)
VALUES
('$_POST[username]','$password','$_POST[email]')";
mysql_query($sql);
header( 'Location: user.php' );
?>
ProsesLogin
<?php
include 'koneksi.php';
session_start();
if(isset($_POST['username'])&& isset($_POST['password'])):
$query_count = mysql_query("select count(*) as jumlah from admin where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result_count = mysql_fetch_object($query_count);
if($result_count->jumlah>0):
$query = mysql_query("select * from admin where username='$_POST[username]' AND password=MD5('$_POST[password]')");
$result = mysql_fetch_object($query);
$_SESSION['id_user'] = $result->id_user;
$_SESSION['login_status'] = true;
echo '<script>alert("sukses tos sok"); location.href="admin.php";</script>';
else:
echo '<script>alert("Username dan password yang anda masukan salah"); location.href="login.php";</script>';
endif;
else:
echo '<script>alert("Username dan Password harus di isi"); location.href="login.php";</script>';
endif;
?>
Logout
<?php
session_start();
unset($_SESSION['login_status']);
echo '<script>alert("anda sudah logout"); location.href="login.php";</script>';
?>
Login
<?php
session_start();
if($_SESSION['login_status']) echo '<script>alert("anda harus login terlebih dahulu"); location.href="admin.php";</script>';
?>
<form method="post" action="proseslogin.php">
Username : <input type="text" name="username"><br>
Password : <input type="password" name="password"><br>
<input type="submit" value="log in">
</form>
List_berita
<?php
session_start();
include "koneksi.php";
if(!$_SESSION['login_status'])
echo '<script>alert("anda harus login dulu");location.href="login.php";</script>';
if(isset($_POST['judul']) && isset($_POST['isi'])):
$date = date('Y-m-d');
$status = mysql_query("insert into berita(`judul`,`isi`,`tanggal`) values('$_POST[judul]','$_POST[isi]','".$date."')");
if($status):echo '<script>location.href="list_berita.php";</script>';
else : echo '<script>alert("gagal");location.href="list_berita.php";</script>';
endif;
endif;
?>
<?php if(isset($_GET['action']) && $_GET['action']=='tambah') :?>
<form method="post" action="list_berita.php">
<label>Judul</label> <input type="text" name="judul"><br>
<label>Konten</label> <textarea name="isi"></textarea><br>
<input type="submit" value="Submit">
</form>
<?php else : ?>
<a href="?action=tambah">Tambah Berita</a>
<table>
<tr>
<td>No</td>
<td>Judul</td>
<td>Isi</td>
<td>aksi</td>
</tr>
<?php $i=1; ?>
<?php $result = mysql_query("select * from berita"); ?>
<?php while($row = mysql_fetch_object($result)): ?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row->judul; ?></td>
<td><?php echo $row->isi; ?></td>
<td>
<a href="hapus_berita.php?id_berita= <?php echo $row->id_berita ?>" onClick="return confirm('ciyus??')">Hapus</a>
<a href="edit_berita.php?id_berita= <?php echo $row->id_berita ?>">Edit</a>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
SQL
http://www.4shared.com/zip/bqrks200/prak9pwdsql.html
Home Bostr
<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<a class="brand" href="#">Responsi Web Dinamis</a>
<ul class="nav">
<li class="active"><a href="#">Berita</a></li>
<li><a href="list_berita.php">Dasbor</a></li>
<li><a href="login.php">Login</a></li>
</ul>
</div>
</div>
<br><br><br>
<div class="hero-unit">
<table width"500"><tr><td>
<div id="myCarousel" class="carousel slide">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item"><img src="img/........." align="center" width="600" height="50"></div>
<div class="item"><img src="img/......." align="center" width="600" height="50"></div>
<div class="item"><img src="img/......." align="center" width="600" height="50"></div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</td>
<td>
<table align="center" width="400"><tr><td>
<address>
<strong>Yogyakarta, Ina.</strong><br>
UNIVERSITAS AHMAD DAHLAN<br>
Jln, Supomo<br>
<abbr title="Phone">P:</abbr> 085363050136
</address>
<address>
<strong>Catur Prasongko (10018032)</strong><br>
<a href="mailto:#">caturprasongko@yahoo.co.id</a>
</address>
</td></tr></table>
</td>
</tr></table>
</div>
<table align="center" width="900"><tr><td>
<?php
include "koneksi.php";
$berita = mysql_query("SELECT * FROM berita");
while($row = mysql_fetch_object($berita)):
echo "<h1>".$row->judul."</h1>";
echo "<small>".$row->tanggal."</small>";
echo "<p>".$row->isi."</p><br>";
echo "<hr>";
$komentar = mysql_query("SELECT * FROM komentar where id_berita = ".$row->id_berita);
while($komen = mysql_fetch_object($komentar)):
echo $komen->nama." : ";
echo "<i>".$komen->komentar."</i><br><br>";
endwhile;
echo "<br>";
?>
<form method="POST" action="post_komentar.php">
<input type="hidden" name="id_berita" value="<?php echo $row->id_berita?>">
<table><tr><td>
nama </td><td><input type="text" name="nama"></input><br></td></tr>
<tr><td> email </td><td><input type="email" name="email"></input><br></td></tr>
<tr><td>url </td><td><input type="text" name="url"></input><br></td></tr>
<tr><td> komentar </td><td><textarea name="komentar"></textarea><br></td></tr>
<tr><td> </td><td><input type="submit" value="kirim"><br></td></tr></table>
</form>
<?php
endwhile;
?>
</td></tr></table>
</body>
</html>
1 Comments
scrip apa nih gan
ReplyDelete