WEB

koneksi.php

<?php
$server="localhost";
$username="root";
$password="";
$db="web";

mysql_connect("$server","$username","$password") or die ("koneksi Gagal.!!");
mysql_select_db("$db") or die ("database tidak ditemukan");

?>

input.php

<?php
include "auth.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>K-Rony27</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.png">
</head>

<body>
<div id="wrapper">
  <div id="header"></div>
  <div id="leftcontent">
  <div id="menu">
<li class="active"><a href="index1.php">Home</a></li>
            <li><a href="show.php">Lihat Data</a></li>
    <li><a href="input.php">Input</a></li>
<li><a href="edit.php">Edit</a></li>
<li><a href="hapus.php">Hapus</a></li>    
    </div><br /><br /><hr />
    <center><h1>INPUT DATA</h1><hr />
    </center>
<form action="inputdata.php" method="post">
<table width="551" border="0">
  <tr>
    <td>Kode Penulis</td>
    <td><input type="text" name="kodepenulis" id="kdpenulis"/></td>
  </tr>
  <tr>
    <td>Tanggal Upload</td>
    <td><input type="date" name="tglupload" id="tglupload" value="yy/mm/dd" onFocus="this.value=''"></td>
  </tr>
  <tr>
    <td>Setuju Admin</td>
    <td>
    <select name="setujuadmin">
    <option>Yes</option>
    <option>No</option>
    </select>
  </tr>
  <tr>
    <td>Judul</td>
    <td><input type="text" name="judul" id="judul"></td>
  </tr>
  <tr>
    <td>Lead</td>
    <td><input type="text" name="lead" id="lead"></td>
  </tr>
  <tr>
    <td>Isi Berita</td>
    <td><textarea name="isiberita" cols="50" rows="10" id="isi"> </textarea></td>
  </tr>
  <tr>
    <td>Footer</td>
    <td><input type="text" name="footer" id="foot"/></td>
  </tr>
  <tr>
    <td>kode bagian</td>
    <td><input type="text" name="kodebag" id="kdbag"/></td>
  </tr>
  <tr>
    <td>Honor</td>
    <td><input type="text" name="honor" id="honor"/></td>
  </tr>
  <tr><td></td><td><input type="submit" value="Input Data" /><input type="reset" value="Reset" /></td></tr>
</table>

</form>
  </div>
  <div id="rightcontent">
  
  </div>
  <div id="clearer"></div>
  <div id="footer">Copyright &copy; 2012 by K-Rony27.co.cc. All Rights Reserved.</div>
</div>
</body>
</html>

inputdata.php

<?php
include "koneksi.php";
$kodepenulis=htmlspecialchars($_POST['kodepenulis']);
$tglupload=htmlspecialchars($_POST['tglupload']);
$setujuadmin=htmlspecialchars($_POST['setujuadmin']);
$judul=htmlspecialchars($_POST['judul']);
$lead=htmlspecialchars($_POST['lead']);
$isiberita=htmlspecialchars($_POST['isiberita']);
$footer=htmlspecialchars($_POST['footer']);
$kodebag=htmlspecialchars($_POST['kodebag']);
$honor=htmlspecialchars($_POST['honor']);

if (empty($kodepenulis))
{
die('<script language="javascript">alert ("Isikan kode penulis..!!!!");</script>');
}
elseif(empty($tglupload))
{
die('<script language="javascript">alert ("Isikan tanggal..!!!!");</script>');
}
else
{
$cekdata="select kodepenulis from berita where kodepenulis=$kodepenulis";
$ada=mysql_query($cekdata) or die (mysql_error());
if(mysql_num_rows($ada)>0)
{die ("kode penulis telah terdaftar");}
}
mysql_query("insert into berita(kodepenulis,tglupload,setujuadmin,judul,lead,isiberita,footer,kodebag,honor)".
"value ('$kodepenulis','$tglupload','$setujuadmin','$judul','$lead','$isiberita','$footer','$kodebag','$honor')") or die (mysql_error());
echo"berhasil";
header("location:show.php");
?>

Show.php

<?php
include "koneksi.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>K-Rony27</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.png">
</head>

<body>
<font size="-3">
<div id="wrapper">
  <div id="header"></div>
  <div id="leftcontent">
  <div id="menu">
<li class="active"><a href="index1.php">Home</a></li>
            <li><a href="show.php">Lihat Data</a></li>
    <li><a href="input.php">Input</a></li>
<li><a href="edit.php">Edit</a></li>
<li><a href="hapus.php">Hapus</a></li>
    </div><br /><br /><hr />
    <center><h1>TAMPIL DATA</h1><hr /></center>
  <table width="140%" align="center" border="1" cellpadding="3" cellspacing="0">
  <tr>
    <td align="center"  width="10">Kode Penulis</td>
        <td align="center">Tanggal Upload</td>
        <td width="10">Setuju Admin</td>
        <td align="center">Judul</td>
        <td align="center">Lead</td>
        <td align="center">Isi Berita</td>
        <td align="center">Footer</td>
        <td align="center">Kode Bagian</td>
        <td align="center">Honor</td>
    </tr>
  <?php
  {
  $show="select kodepenulis,tglupload,setujuadmin,judul,lead,isiberita,footer,kodebag,honor from berita";
  }
  $tampil=mysql_query($show) or die (mysql_error());
  while ($data=mysql_fetch_object($tampil))
 {
 ?>
 <tr>
  <td align="center"><?php echo $data->kodepenulis ?></td> 
    <td align="center"><?php echo $data->tglupload ?></td>
    <td align="center"><?php echo $data->setujuadmin ?></td>
    <td align="center"><?php echo $data->judul ?></td>
    <td align="center"><?php echo $data->lead ?></td>
    <td align="justify"><?php echo $data->isiberita ?></td>
    <td align="center"><?php echo $data->footer ?></td>
    <td align="center"><?php echo $data->kodebag ?></td>
    <td align="center"><?php echo $data->honor ?></td>
    </tr>
<?php
 }
 ?>
</table>
<br />
  </div>
  <div id="clearer"></div>
  <div id="footer">Copyright &copy; 2012 by K-Rony27.co.cc. All Rights Reserved.</div>
</div>
</body>
</html>

edit.php

<?php
include "koneksi.php";
include "auth.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>K-Rony27</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.png">
</head>

<body>
<font size="-3">
<div id="wrapper">
  <div id="header"></div>
  <div id="leftcontent">
  <div id="menu">
<li class="active"><a href="index1.php">Home</a></li>
            <li><a href="show.php">Lihat Data</a></li>
    <li><a href="input.php">Input</a></li>
    <li><a href="edit.php">Edit</a></li>
<li><a href="hapus.php">Hapus</a></li>
    </div><br /><br /><hr />
    <center><h1>EDIT DATA</h1><hr /></center>
  <table width="140%" align="center" border="1" cellpadding="3" cellspacing="0">
  <tr>
    <td align="center"  width="10">Kode Penulis</td>
        <td align="center">Tanggal Upload</td>
        <td width="10">Setuju Admin</td>
        <td align="center">Judul</td>
        <td align="center">Lead</td>
        <td align="center">Isi Berita</td>
        <td align="center">Footer</td>
        <td align="center">Kode Bagian</td>
        <td align="center">Honor</td>
        <td align="center">Edit</td>
    </tr>
  <?php
  {
  $show="select kodepenulis,tglupload,setujuadmin,judul,lead,isiberita,footer,kodebag,honor from berita";
  }
  $tampil=mysql_query($show) or die (mysql_error());
  while ($data=mysql_fetch_object($tampil))
 {
 ?>
 <tr>
  <td align="center"><?php echo $data->kodepenulis ?></td> 
    <td align="center"><?php echo $data->tglupload ?></td>
    <td align="center"><?php echo $data->setujuadmin ?></td>
    <td align="center"><?php echo $data->judul ?></td>
    <td align="center"><?php echo $data->lead ?></td>
    <td align="justify"><?php echo $data->isiberita ?></td>
    <td align="center"><?php echo $data->footer ?></td>
    <td align="center"><?php echo $data->kodebag ?></td>
    <td align="center"><?php echo $data->honor ?></td>
    <td align="center"><a href="aksi_edit.php?kodepenulis=<?php echo $data->kodepenulis ?>">Edit</a></td>
    </tr>
<?php
 }
 ?>
</table>
<br />
  </div>
  <div id="clearer"></div>
  <div id="footer">Copyright &copy; 2012 by K-Rony27.co.cc. All Rights Reserved.</div>
</div>
</body>
</html>

Update.php

<?php
include "koneksi.php";

$kodepenulis=htmlspecialchars($_POST['kodepenulis']);
$tglupload=htmlspecialchars($_POST['tglupload']);
$setujuadmin=htmlspecialchars($_POST['setujuadmin']);
$judul=htmlspecialchars($_POST['judul']);
$lead=htmlspecialchars($_POST['lead']);
$isiberita=htmlspecialchars($_POST['isiberita']);
$footer=htmlspecialchars($_POST['footer']);
$kodebag=htmlspecialchars($_POST['kodebag']);
$honor=htmlspecialchars($_POST['honor']);
$update=mysql_query("UPDATE berita SET kodepenulis='$kodepenulis',tglupload='$tglupload',setujuadmin='$setujuadmin',judul='$judul',lead='$lead',isiberita='$isiberita',footer='$footer',kodebag='$kodebag',honor='$honor' WHERE kodepenulis=$kodepenulis");

if($update){ echo "Data berhasil diupdate"; }else{ echo "gagal"; } 
header("location:show.php");
?>

aksi edit.php

<?php 
include "koneksi.php";
include "auth.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>K-Rony27</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.png">
</head>

<body>
<div id="wrapper">
  <div id="header"></div>
  <div id="leftcontent">
  <div id="menu">
<li class="active"><a href="index1.php">Home</a></li>
            <li><a href="show.php">Lihat Data</a></li>
    <li><a href="input.php">Input</a></li>
<li><a href="edit.php">Edit</a></li>
<li><a href="hapus.php">Hapus</a></li>    
    </div><br /><br /><hr />
    <center><h1>EDIT-UPDATE DATA</h1><hr /></center>
<?php
$kodepenulis=$_GET['kodepenulis'];
$query_update=mysql_query("select * from berita where kodepenulis='$kodepenulis' LIMIT 1");
$data=mysql_fetch_object($query_update);
?>
<form action="update.php" method="post">
<table width="140%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>Kode Penulis</td>
    <td>:</td>
    <td><input name="kodepenulis" type="text" value="<?php echo $data->kodepenulis ?>" /></td>
</tr>
<tr>
<td>Tanggal Upload</td>
    <td>:</td>
    <td><input name="tglupload" type="date" value="<?php echo $data->tglupload ?>" /></td>
</tr>
<tr>
<td>Setuju Admin</td>
    <td>:</td>
    <td><select name="setujuadmin">
    <option><?php echo $data->setujuadmin ?></option>
    </select></td>
<tr>
<td>Judul</td>
    <td>:</td>
    <td><input name="judul" type="text" value="<?php echo $data->judul ?>" /></td>
</tr>
<tr>
<td>Lead</td>
    <td>:</td>
    <td><input name="lead" type="text" value="<?php echo $data->lead ?>" /></td>
</tr>
<tr>
<td>Isi Berita</td>
    <td>:</td>
    <td><textarea name="isiberita" cols="50" rows="10"><?php echo $data->isiberita ?></textarea></td>
</tr>
<tr>
<td>Footer</td>
    <td>:</td>
    <td><input name="footer" value="<?php echo $data->footer?>" /></td>
</tr>
<tr>
<td>Kode Bagian</td>
    <td>:</td>
    <td><input name="kodebag" value="<?php echo $data->kodebag ?>" /></td>
</tr>
<tr>
<td>Honor</td>
    <td>:</td>
    <td><input name="honor" value="<?php echo $data->honor ?>" /></td>
</tr>
<tr>
<td></td><td></td>
    <td><input name="fok" type="submit" value="Update" />
    <input name="fulang" type="reset" value="Ulangi" />
    <input name="fulang" type="button" value="Batal" onclick="javascript:history.back()" /></td>
</tr>
</table>
</form>
<br />
    </div>
    <div id="clearer"></div>
  <div id="footer">Copyright &copy; 2012 by K-Rony27.co.cc. All Rights Reserved.</div>
</div>
</body>
</html>

Hapus.php

<?php
include "koneksi.php";
include "auth.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>K-Rony27</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.png">
</head>

<body>
<div id="wrapper">
  <div id="header"></div>
  <div id="leftcontent">
  <div id="menu">
<li class="active"><a href="index1.php">Home</a></li>
            <li><a href="show.php">Lihat Data</a></li>
    <li><a href="input.php">Input</a></li>
<li><a href="edit.php">Edit</a></li>
<li><a href="hapus.php">Hapus</a></li>    
    </div><br /><br /><hr />
    <center><h1>HAPUS DATA</h1><hr /></center>
<?php
$kodepenulis = $_GET['kodepenulis']; 
$del = mysql_query("DELETE FROM berita where kodepenulis=$kodepenulis"); 
if($del){ echo "Data berhasil di delete"; }else{ echo "Gagal"; 
  //header("location:show.php");
  ?>
  
  </div>
  <div id="rightcontent">
  
  </div>
  <div id="clearer"></div>
  <div id="footer">Copyright &copy; 2012 by K-Rony27.co.cc. All Rights Reserved.</div>
</div>
</body>
</html>

Comments

Popular posts from this blog

Entity Relationship Diagram (ERD) Minimarket

Sistem Informasi Pertanahan

RPL