Master-master sekalian...............
gimana cara / script untuk Upload File PDF dan Menampilkan Data Upload (file pdf) Dalam Tabel serta mendownload File PDF tersebut.

saya masih bingung ni master.... mohon bantuannya
Silahkan login untuk menjawab!
1
Loading...
hamkagood · Nov 5, 2012 · 1 Suka · 0 Tidak Suka
Mungkin ini bisa membantu:
upload_file.php
<?php require_once('Connections/koneksi.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 if (PHP_VERSION < 6) {
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 }
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
 case "text":
 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 break; 
 case "long":
 case "int":
 $theValue = ($theValue != "") ? intval($theValue) : "NULL";
 break;
 case "double":
 $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
 break;
 case "date":
 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 break;
 case "defined":
 $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
 break;
 }
 return $theValue;
}
}
$maxRows_rsGalery = 10;
$pageNum_rsGalery = 0;
if (isset($_GET['pageNum_rsGalery'])) {
 $pageNum_rsGalery = $_GET['pageNum_rsGalery'];
}
$startRow_rsGalery = $pageNum_rsGalery * $maxRows_rsGalery;
mysql_select_db($database_koneksi, $koneksi);
$query_rsGalery = "SELECT * FROM myfile ORDER BY id DESC";
$query_limit_rsGalery = sprintf("%s LIMIT %d, %d", $query_rsGalery, $startRow_rsGalery, $maxRows_rsGalery);
$rsGalery = mysql_query($query_limit_rsGalery, $koneksi) or die(mysql_error());
$row_rsGalery = mysql_fetch_assoc($rsGalery);
if (isset($_GET['totalRows_rsGalery'])) {
 $totalRows_rsGalery = $_GET['totalRows_rsGalery'];
} else {
 $all_rsGalery = mysql_query($query_rsGalery);
 $totalRows_rsGalery = mysql_num_rows($all_rsGalery);
}
$totalPages_rsGalery = ceil($totalRows_rsGalery/$maxRows_rsGalery)-1;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
 $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
 // Upload file code goes here
 $target = "upload/"; //This is the directory where file will be uploaded//
 $target = $target . basename( $_FILES['nama_file']['name']); //change the image and name to whatever your database fields are called//
 $insertSQL = sprintf("INSERT INTO myfile (judul_file, deskripsi_file, nama_file) VALUES (%s, %s, %s)",
 GetSQLValueString($_POST['judul_file'], "text"),
 GetSQLValueString($_POST['deskripsi_file'], "text"),
 GetSQLValueString($_FILES['nama_file']['name'], "text"));

 //This code writes the photo to the server// 
 if(move_uploaded_file($_FILES['nama_file']['tmp_name'], $target)) 
 { 

 mysql_select_db($database_koneksi, $koneksi);
 $Result1 = mysql_query($insertSQL, $koneksi) or die(mysql_error());
$insertGoTo = "upload_file.php?file=uploaded";
 if (isset($_SERVER['QUERY_STRING'])) {
 $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
 $insertGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $insertGoTo));
 }else{
 header(sprintf("Location: upload_file.php?file=error"));
 }
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial Upload File</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<?php if(isset($_GET['file']) && ($_GET['file']=="uploaded")) { ?>
<h1>Terimakasih, file Anda berhasil diupload</h1>
<h3><strong><?php echo $row_rsGalery['judul_file']; ?></strong></h3>
<p><?php echo nl2br($row_rsGalery['deskripsi_file']); ?></p>
<img src="upload/<?php echo $row_rsGalery['nama_file']; ?>">
<?php }elseif(isset($_GET['file']) && ($_GET['file']=="error")) { ?>
<h1>Mohon maaf, terjadi error dalam proses upload file</h1>
<p><a href="upload_file.php">Ulangi upload file</a></p>
<?php }else{ ?>
<h1><a href="http://www.javawebmedia.com">Home</a> | <a href="http://www.javawebmedia.com">Java Web Media</a> | <a href="http://www.javawebmedia.com/course.php">Course</a> | <a href="http://www.javawebmedia.com/contact.php">Contact Us</a></h1>

 <table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
 <th scope="col">Judul File</th>
 <th width="40%" scope="col">Deskripsi</th>
 <th scope="col">Gambar</th>
 <th scope="col">Action</th>
 </tr>
 <?php do { ?>
 <tr>
 <td><?php echo $row_rsGalery['judul_file']; ?></td>
 <td width="40%"><?php echo nl2br($row_rsGalery['deskripsi_file']); ?></td>
 <td><img src="upload/<?php echo $row_rsGalery['nama_file']; ?>" alt="" name="gambar" width="150" height="100"></td>
 <td><a href="edit_file.php?edit=<?php echo $row_rsGalery['id']; ?>">Edit</a> | <a href="edit_file.php?delete=<?php echo $row_rsGalery['id']; ?>">Delete</a></td>
 </tr>
 <?php } while ($row_rsGalery = mysql_fetch_assoc($rsGalery)); ?>
 <tr>
 <th>Judul File</th>
 <th width="40%">Deskrispsi</th>
 <th>Gambar</th>
 <th>Action</th>
 </tr>
 </table>

<p>&nbsp;</p>
 <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
 <p>
 <label for="judul_file">Judul file:</label>
 <input name="judul_file" type="text" id="judul_file" size="50">
 </p>
 <p>
 <label for="deskripsi_file">Deskripsi file:</label>
 <textarea name="deskripsi_file" id="deskripsi_file" cols="50" rows="5"></textarea>
 </p>
 <p>
 <label for="nama_file">Upload file:</label>
 <input name="nama_file" type="file" id="nama_file" size="40">
 </p>
 <p>
 <input type="submit" name="submit" id="submit" value="Submit">
 <input type="reset" name="submit2" id="submit2" value="Reset">
 </p>
 <input type="hidden" name="MM_insert" value="form1">
 </form>
<?php } ?>
</div>
</body>
</html>
<?php
mysql_free_result($rsGalery);
?>
edit_file.php
<?php require_once('Connections/koneksi.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 if (PHP_VERSION < 6) {
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 }
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
 case "text":
 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 break; 
 case "long":
 case "int":
 $theValue = ($theValue != "") ? intval($theValue) : "NULL";
 break;
 case "double":
 $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
 break;
 case "date":
 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
 break;
 case "defined":
 $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
 break;
 }
 return $theValue;
}
}
$colname_rsEdit = "-1";
if (isset($_GET['edit'])) {
 $colname_rsEdit = $_GET['edit'];
}
mysql_select_db($database_koneksi, $koneksi);
$query_rsEdit = sprintf("SELECT * FROM myfile WHERE id = %s", GetSQLValueString($colname_rsEdit, "int"));
$rsEdit = mysql_query($query_rsEdit, $koneksi) or die(mysql_error());
$row_rsEdit = mysql_fetch_assoc($rsEdit);
$totalRows_rsEdit = mysql_num_rows($rsEdit);
$colname_rsDelete = "-1";
if (isset($_GET['delete'])) {
 $colname_rsDelete = $_GET['delete'];
}
mysql_select_db($database_koneksi, $koneksi);
$query_rsDelete = sprintf("SELECT * FROM myfile WHERE id = %s", GetSQLValueString($colname_rsDelete, "int"));
$rsDelete = mysql_query($query_rsDelete, $koneksi) or die(mysql_error());
$row_rsDelete = mysql_fetch_assoc($rsDelete);
$totalRows_rsDelete = mysql_num_rows($rsDelete);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
 $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
 //Jika gambar tidak diupdate, maka data gambar tidak diganti
 if(empty($_FILES['nama_file']['name'])) {
 // Kode update data tanpa upload file
 $updateSQL = sprintf("UPDATE myfile SET judul_file=%s, deskripsi_file=%s WHERE id=%s",
 GetSQLValueString($_POST['judul_file'], "text"),
 GetSQLValueString($_POST['deskripsi_file'], "text"),
 GetSQLValueString($_POST['id'], "int"));
 }else{
 // Jika file baru diupload, maka file akan diupload dan database akan diganti dengan file baru
 // File lama juga akan dihapus
 $target = "upload/";
 $hapusfile = unlink($target.$row_rsEdit['nama_file']);
 // Jika proses upload file gagal
 if(!$hapusfile) {
 header("Location: edit_file.php?file=error");
 }
 // File baru diupload
 $target = $target . basename( $_FILES['nama_file']['name']); 
 $updateSQL = sprintf("UPDATE myfile SET judul_file=%s, deskripsi_file=%s, nama_file=%s WHERE id=%s",
 GetSQLValueString($_POST['judul_file'], "text"),
 GetSQLValueString($_POST['deskripsi_file'], "text"),
 GetSQLValueString($_FILES['nama_file']['name'], "text"),
 GetSQLValueString($_POST['id'], "int"));
 // Upload file baru 
 move_uploaded_file($_FILES['nama_file']['tmp_name'], $target);
 } // Akhir dari upload file baru
 mysql_select_db($database_koneksi, $koneksi);
 $Result1 = mysql_query($updateSQL, $koneksi) or die(mysql_error());
$updateGoTo = "upload_file.php";
 if (isset($_SERVER['QUERY_STRING'])) {
 $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
 $updateGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST['hapus'])) && ($_POST['hapus'] != "")) {
 $deleteSQL = sprintf("DELETE FROM myfile WHERE id=%s",
 GetSQLValueString($_POST['hapus'], "int"));
// Hapus gambar dan data sekaligus
 $hapus = unlink($_POST['nama_file']);
 // Jika proses hapus gagal, alihkan ke halaman error
 if(!$hapus) {
 header("Location: edit_file.php?file=error");
 }
 mysql_select_db($database_koneksi, $koneksi);
 $Result1 = mysql_query($deleteSQL, $koneksi) or die(mysql_error());
$deleteGoTo = "upload_file.php";
 if (isset($_SERVER['QUERY_STRING'])) {
 $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
 $deleteGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $deleteGoTo));
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial Upload File</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
 <h1><a href="http://www.javawebmedia.com">Home</a> | <a href="http://www.javawebmedia.com">Java Web Media</a> | <a href="http://www.javawebmedia.com/course.php">Course</a> | <a href="http://www.javawebmedia.com/contact.php">Contact Us</a></h1>

 <?php if(isset($_GET['edit'])) { ?>
 <h2>Mengupdate gambar</h2>

 <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
 <p>
 <label for="judul_file">Judul file:</label>
 <input name="judul_file" type="text" id="judul_file" value="<?php echo $row_rsEdit['judul_file']; ?>" size="50">
 </p>
 <p>
 <label for="deskripsi_file">Deskripsi file:</label>
 <textarea name="deskripsi_file" id="deskripsi_file" cols="50" rows="5"><?php echo $row_rsEdit['deskripsi_file']; ?></textarea>
 </p>
 <p>
 <label for="nama_file">Upload file (Biarkan kosong jika tidak ingin mengubah gambar):</label>
 <input name="nama_file" type="file" id="nama_file" size="40">
 </p>
 <p>
 <input type="submit" name="submit" id="submit" value="Update">
 <input name="id" type="hidden" id="id" value="<?php echo $row_rsEdit['id']; ?>">
 <a href="upload_file.php">Cancel</a></p>
 <input type="hidden" name="MM_update" value="form1">
 </form>

 <?php }elseif(isset($_GET['file']) && ($_GET['file']=="error")) { ?>
 <h2 class="warning">Oopss... Terjadi error dalam proses upload file. <a href="upload_file.php">Kembali ke halaman file</a></h2>

 <?php }else{ ?>
 <h2>Menghapus gambar</h2>

 <p class="warning">Yakin ingin menghapus gambar ini?</p>

 <form name="form2" method="post" action="">
 <p>
 <label for="judul_file">Judul gambar:</label>
 <input name="judul_file" type="text" id="judul_file" value="<?php echo $row_rsDelete['judul_file']; ?>" size="50" readonly="readonly">
 </p>
 <p>
 <input type="submit" name="submit" id="submit" value="Hapus gambar">
 <input name="hapus" type="hidden" id="hapus" value="<?php echo $row_rsDelete['id']; ?>">
 <input name="nama_file" type="hidden" id="nama_file" value="upload/<?php echo $row_rsDelete['nama_file']; ?>">
 <a href="upload_file.php">Cancel</a></p>
 </form>
 <?php } ?>
</div>
</body>
</html>
<?php
mysql_free_result($rsEdit);
mysql_free_result($rsDelete);
?>
style.css
body {
 background-color: #063;
 margin: 0px;
 padding: 0px;
}
form {
 background-color: #E7E7E7;
 padding: 20px;
 border: thin solid #CECECE;
 border-radius: 5px;
}
label {
 font-size: 14px;
 font-weight: bold;
 text-transform: capitalize;
 display: block;
}
input {
 padding: 5px 10px;
}
h1 {
 padding-bottom: 10px;
 border-bottom: solid thin #D4D4D4;
 font-size: 18px;
}
a, a:visited {
 text-decoration: none;
}
a:hover {
 color: #900;
}
#wrapper {
 font-family: Tahoma, Geneva, sans-serif;
 background-color: #FFF;
 margin: auto;
 padding: 20px 30px;
 height: auto;
 width: 960px;
 border-right-width: 5px;
 border-right-style: solid;
 border-right-color: #CCC;
 border-bottom-width: 5px;
 border-left-width: 5px;
 border-bottom-style: solid;
 border-left-style: solid;
 border-bottom-color: #CCC;
 border-left-color: #CCC;
 border-bottom-left-radius: 5px;
 border-bottom-right-radius: 5px;
}
img {
 max-width: 900px;
 padding: 10px;
 border: solid thin #F9F;
 background-color: #FFC;
 height: auto;
}
.warning {
 background-color: #FCF;
 color: #900;
 padding: 5px 10px;
 border: solid thin #900;
 border-radius: 5px;
}
#header {
 width: 960px;
 height: 100px;
 float: left;
 font-size: 16px;
 padding: 10px 0px;
 margin-bottom: 10px;
}
#header h1 {
 font-size: 20px;
 color: #060;
 border-bottom: none;
}
#navigasi {
 float: left;
 width: 960px;
 height: 40px;
 color: #FFF;
 background-color: #333;
 margin-bottom: 10px;
}
#konten {
 width: 960px;
 height: auto;
 float: left;
 padding-bottom: 20px;
 margin-bottom: 10px;
 border-bottom: solid thin #CCC;
}
#footer {
 text-align: center;
 font-size: 11px;
}
table {
 border: solid thin #090;
 font-size: 12px;
}
th, td {
 text-align: left;
 vertical-align: top;
 border-bottom: solid thin #090;
 padding: 10px;
}
th {
 background-color: #060;
 color: #fff;
 font-weight: bold;
 font-size: 14px;
}

0
Loading...
fadixz · Nov 12, 2012 · 0 Suka · 0 Tidak Suka
pegawai.sql
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 12, 2012 at 03:10 AM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `diklat`
--

--

--
-- Table structure for table `pegawai`
--

CREATE TABLE IF NOT EXISTS `pegawai` (
`no_sertifikat` varchar(50) NOT NULL,
`nip` char(18) NOT NULL,
`nama` varchar(50) NOT NULL,
`tempat_lahir` varchar(30) NOT NULL,
`tanggal_lahir` date NOT NULL,
`jk` enum('L','P') NOT NULL DEFAULT 'L',
`pangkat` char(26) NOT NULL,
`jabatan` varchar(50) NOT NULL,
`instansi` varchar(70) NOT NULL,
`jenis_diklat` varchar(50) NOT NULL,
`berkas` varchar(30) NOT NULL, // upload jenis file pdf, rar atau zip
PRIMARY KEY (`no_sertifikat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `pegawai`
--

INSERT INTO `pegawai` (`no_sertifikat`, `nip`, `nama`, `tempat_lahir`, `tanggal_lahir`, `jk`, `pangkat`, `jabatan`, `instansi`, `jenis_diklat`, `berkas`) VALUES
('12123232131', '123214314134', '', '', '1950-01-01', 'L', '-', '', '', '-', '');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
form input pegawai.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Entry Pegawai</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.data {
font-family: Verdana, Geneva, sans-serif;
}
.menu {
font-family: Verdana, Geneva, sans-serif;
}
</style>
</head>
<body>
<p align="center">
<a href="index.php" class="menu"> MENU UTAMA</a>&nbsp;
<a href="laporan-data-pegawai.php" class="data"> DATA TERINPUT</a>
</p>
<form action="simpan-data-pegawai.php" method="post" enctype="multipart/form-data" name="FPEG">
<table width="615" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#669900">
<tr>
<td width="613" height="40" align="center" bgcolor="#669900"><strong><font color="#FFFFFF">ENTRY DATA PEGAWAI YANG TELAH DIKLAT</font></strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="625" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="139">Nomor Sertifikat</td>
<td width="3">:</td>
<td width="200"><input name="no_sertifikat" type="text" id="no_sertifikat" size="50" maxlength="50"></td>
</tr>

<tr>
<td width="139">NIP</td>
<td width="3">:</td>
<td width="200"><input name="nip" type="text" id="nip" size="18" maxlength="18"></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="nama" type="text" id="nama" size="50" maxlength="50"></td>
</tr>
<tr>
<td>Tempat Lahir</td>
<td>:</td>
<td><input name="tempat_lahir" type="text" id="tempat_lahir" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Tanggal Lahir</td>
<td>:</td>
<td><select name="tgl" size="1" id="tgl">
<?
for ($i=1;$i<=31;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
<select name="bln" size="1" id="bln">
<?
$bulan=array("","Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
for ($i=1;$i<=12;$i++)
{
echo "<option value=".$i.">".$bulan[$i]."</option>";
}
?>
</select>
<select name="thn" size="1" id="thn">
<?
for ($i=1950;$i<=1999;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td>:</td>
<td><input name="jenis_kelamin" type="radio" value="L" checked>
Laki-laki
<input name="jenis_kelamin" type="radio" value="P">
Perempuan </td>
</tr>

<tr>
<td>Pangkat / Golongan</td>
<td>:</td>
<td><select name="pangkat" size="1">
<option selected value="-">--- Pilih Salah Satu ---</option>
<option value="Juru Muda / I.a">Juru Muda / I.a</option>
<option value="Juru Muda Tk. I / I.b">Juru Muda Tk. I / I.b</option>
<option value="Juru / I.c">Juru / I.c</option>
<option value="Juru Tk. I / I.d">Juru Tk. I / I.d</option>
<option value="Pengatur Muda / II.a">Pengatur Muda / II.a</option>
<option value="Pengatur Muda Tk. I / II.b">Pengatur Muda Tk. I / II.b</option>
<option value="Pengatur / II.c">Pengatur / II.c</option>
<option value="Pengatur Tk. I / II.d">Pengatur Tk. I / II.d</option>
<option value="Penata Muda / III.a">Penata Muda / III.a</option>
<option value="Penata Muda Tk. I / III.b">Penata Muda Tk. I / III.b</option>
<option value="Penata / III.c">Penata / III.c</option>
<option value="Penata Tk. I / III.d">Penata Tk. I / III.d</option>
<option value="Pembina / IV.a">Pembina / IV.a</option>
<option value="Pembina Tk. I / IV.b">Pembina Tk. I / IV.b</option>
<option value="Pembina Utama Muda / IV.c">Pembina Utama Muda / IV.c</option>
<option value="Pembina Utama Madya / IV.d">Pembina Utama Madya / IV.d</option>
<option value="Pembina Utama / IV.e">Pembina Utama / IV.e</option>
<option value="PTT">PTT</option>
</select>
</td>
</tr>

<tr>
<td>Jabatan</td>
<td>:</td>
<td><input name="jabatan" type="text" id="jabatan" size="50" maxlength="50"></td>
</tr>
<tr>
<td>Instansi</td>
<td>:</td>
<td><input name="instansi" type="text" id="instansi" size="70" maxlength="70">
</td>
</tr>

<tr>
<td>Jenis Diklat</td>
<td>:</td>
<td><select name="jenis_diklat" size="1">
<option selected value="-">--- Pilih Salah Satu ---</option>
<option value="Diklatpim Tk. I">Diklatpim Tk. I</option>
<option value="Diklatpim Tk. II">Diklatpim Tk. II</option>
<option value="Diklatpim Tk. III">Diklatpim Tk. III</option>
<option value="Diklatpim Tk. IV">Diklatpim Tk. IV</option>
<option value="Diklat Prajabatan CPNSD">Diklat Prajabatan CPNSD</option>
<option value="Diklat Manajemen Kepegawaian">Diklat Manajemen Kepegawaian</option>
<option value="Diklat Bendahara Pengeluaran">Diklat Bendahara Pengeluaran</option>
<option value="Diklat Pejabat Penatausahaan Keuangan">Diklat Pejabat Penatausahaan Keuangan</option>
<option value="Pelatihan / Orientasi PTT">Pelatihan / Orientasi PTT</option>
</select>
</td>
</tr>
<tr>
<td>Berkas Diklat</td>
<td>:</td>
<td><input type="file" name="doc" id="berkas"></td>
</tr>
<tr>
<td colspan="3" align="center"><input name="fok" type="submit" id="fok" value="OK">
<input name="fulang" type="reset" id="fulang" value="Ulangi">
<input name="fulang2" type="button" id="fulang2" value="Batal" onClick="javascript:history.back()"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>


<?
include "koneksi.php";
$no_sertifikat=$_POST;
$nip=$_POST;
$nama=$_POST;
$tempat_lahir=$_POST;
$tanggal_lahir = $_POST."-".$_POST."-".$_POST;
$jk=$_POST;
$pangkat=$_POST;
$jabatan=$_POST;
$intansi=$_POST;
$jenis_diklat=$_POST;
if (empty($id))
{
die("Isikan Nomor Sertifikat Diklat!");
}
elseif(empty($nip))
{
die("Isikan NIP!");
}
else
{
$cekdata="select id from pegawai where id='$id'";
$ada=mysql_query($cekdata) or die(mysql_error());
if(mysql_num_rows($ada)>0)
{ die("Nomor Sertifikat telah Terdaftar!"); }
else
{
if (isset($_POST) && isset($_FILES)) {
$dir = './berkas/';
$file = $_FILES;
$name = $_FILES;
$info = pathinfo($name);
$size = filesize ($file);
if ($size > 1000000){
exit('UKURAN FILE TERLALU GEDHE, CARI NYANG LAEN');
}
$ext = $info;
if(($ext == 'pdf') || ($ext == 'rar')){
if (!is_uploaded_file($file)) {
exit('GAG ADA FILE...');
}
if (!move_uploaded_file($file, $dir.$name)) {
echo 'Unable to upload file';
} else {
echo 'FILE BERHASIL DI-UPLOAD';
}
} else {
echo('CUMAN BOLEH UPLOAD PDF atau RAR');
}
}
mysql_query("insert into pegawai(no_sertifikat,nip,nama,tempat_lahir,tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas)" .
"values('$no_sertifikat','$nip','$nama','$tempat_lahir','$tanggal_lahir','$jk','$pangkat','$jabatan','$intansi','$jenis_diklat','$berkas')") or die(mysql_error());
echo "Berhasil";
header("location:laporan-data-pegawai.php");
} //end if terdaftar
}
?>
<html>
<head>
<title>Laporan Data Pegawai</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h3 align="center" class="telah">Data Pegawai Yang Telah Diklat</h3>
<form action="" method="get" name="FCari" id="FCari">
Cari NIP /Nama
<input name="txtcari" type="text" id="txtcari" size="20" maxlength="30" value="<?php echo $_GET?>">
<input type="submit" name="Submit" value="Cari">
</form>
<p align="left">
<span class="gabung"><a href="index.php">MENU UTAMA</a>&nbsp;
<a href="input-pegawai.php">INPUT DATA</a></span>
</p>
<form name="FLaporan" method="post" action="delete-banyak.php" onSubmit="return confirm('Hapus data terpilih?')">
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td align="center">&nbsp;</td>
<td >Nomor Sertifikat</td>
<td>NIP</td>
<td >Nama</td>
<td >Tempat Lahir</td>
<td >Tanggal Lahir</td>
<td >Jenis Kelamin</td>
<td >Pangkat</td>
<td >Jabatan</td>
<td >Instansi</td>
<td >Jenis Diklat</td>
<td >Berkas</td>
<td >Lanjut</td>
</tr>
<?
include "koneksi.php";
$query=mysql_query ("select * from pegawai", $koneksi) or die (mysql_error());
$jumlah = mysql_num_rows($query);
echo "Jumlah Data Terentry : $jumlah";
$txtcari=$_GET;
if(isset($txtcari))
{
$myquery="select id,nip,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas from pegawai where nip='$txtcari' or nama LIKE '%$txtcari%'";
}
else
{
$myquery="select id,nip,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas from pegawai";
}
$daftarpegawai=mysql_query($myquery) or die (mysql_error());
while($dataku=mysql_fetch_object($daftarpegawai))
{
?>
<tr>
<td align="center">
<input type="checkbox" name="item[]" id="item[]" value="<?php echo $dataku->id?>" /></td>
<td ><?php echo $dataku->id?></td>
<td ><?php echo $dataku->nip?></td>
<td ><?php echo $dataku->nama?></td>
<td ><?php echo $dataku->tempat_lahir?></td>
<td ><?php echo $dataku->tanggal_lahir?></td>
<td ><?php echo $dataku->jk?></td>
<td ><?php echo $dataku->pangkat?></td>
<td ><?php echo $dataku->jabatan?></td>
<td ><?php echo $dataku->instansi?></td>
<td ><?php echo $dataku->jenis_diklat?></td>
<td> <?php echo $dataku->berkas?></td>

<td align="center"><a href="koreksi-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Koreksi</a></td>

<td align="center"><a href="hapus-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Hapus</a></td>
<td align="center"> <a href="download-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Download</a></td>
</tr>
<?
}
?>
</table>
<input name="btnHapus" type="submit" value="Delete" onsubmit="return confirm ('hapus data yang dipilih')">
</form>
</body>
</html>
nah data berkas yang bertife pdf tidak masuk/tampil di tabel laporan-data-pegawai.php.
gimana tu master-master sekalian??????...............
0
Loading...
fadixz · Nov 12, 2012 · 0 Suka · 0 Tidak Suka
pegawai.sql
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 12, 2012 at 03:10 AM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `diklat`
--

--
--
-- Table structure for table `pegawai`
--

CREATE TABLE IF NOT EXISTS `pegawai` (
`no_sertifikat` varchar(50) NOT NULL,
`nip` char(18) NOT NULL,
`nama` varchar(50) NOT NULL,
`tempat_lahir` varchar(30) NOT NULL,
`tanggal_lahir` date NOT NULL,
`jk` enum('L','P') NOT NULL DEFAULT 'L',
`pangkat` char(26) NOT NULL,
`jabatan` varchar(50) NOT NULL,
`instansi` varchar(70) NOT NULL,
`jenis_diklat` varchar(50) NOT NULL,
`berkas` varchar(30) NOT NULL, // upload jenis file pdf, rar atau zip
PRIMARY KEY (`no_sertifikat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `pegawai`
--

INSERT INTO `pegawai` (`no_sertifikat`, `nip`, `nama`, `tempat_lahir`, `tanggal_lahir`, `jk`, `pangkat`, `jabatan`, `instansi`, `jenis_diklat`, `berkas`) VALUES
('12123232131', '123214314134', '', '', '1950-01-01', 'L', '-', '', '', '-', '');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; form input pegawai.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Entry Pegawai</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.data {
font-family: Verdana, Geneva, sans-serif;
}
.menu {
font-family: Verdana, Geneva, sans-serif;
}
</style>
</head>
<body>
<p align="center">
<a href="index.php" class="menu"> MENU UTAMA</a>&nbsp;
<a href="laporan-data-pegawai.php" class="data"> DATA TERINPUT</a>
</p>
<form action="simpan-data-pegawai.php" method="post" enctype="multipart/form-data" name="FPEG">
<table width="615" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#669900">
<tr>
<td width="613" height="40" align="center" bgcolor="#669900"><strong><font color="#FFFFFF">ENTRY DATA PEGAWAI YANG TELAH DIKLAT</font></strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="625" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="139">Nomor Sertifikat</td>
<td width="3">:</td>
<td width="200"><input name="no_sertifikat" type="text" id="no_sertifikat" size="50" maxlength="50"></td>
</tr>

<tr>
<td width="139">NIP</td>
<td width="3">:</td>
<td width="200"><input name="nip" type="text" id="nip" size="18" maxlength="18"></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input name="nama" type="text" id="nama" size="50" maxlength="50"></td>
</tr>
<tr>
<td>Tempat Lahir</td>
<td>:</td>
<td><input name="tempat_lahir" type="text" id="tempat_lahir" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Tanggal Lahir</td>
<td>:</td>
<td><select name="tgl" size="1" id="tgl">
<?
for ($i=1;$i<=31;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
<select name="bln" size="1" id="bln">
<?
$bulan=array("","Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
for ($i=1;$i<=12;$i++)
{
echo "<option value=".$i.">".$bulan[$i]."</option>";
}
?>
</select>
<select name="thn" size="1" id="thn">
<?
for ($i=1950;$i<=1999;$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td>:</td>
<td><input name="jenis_kelamin" type="radio" value="L" checked>
Laki-laki
<input name="jenis_kelamin" type="radio" value="P">
Perempuan </td>
</tr>

<tr>
<td>Pangkat / Golongan</td>
<td>:</td>
<td><select name="pangkat" size="1">
<option selected value="-">--- Pilih Salah Satu ---</option>
<option value="Juru Muda / I.a">Juru Muda / I.a</option>
<option value="Juru Muda Tk. I / I.b">Juru Muda Tk. I / I.b</option>
<option value="Juru / I.c">Juru / I.c</option>
<option value="Juru Tk. I / I.d">Juru Tk. I / I.d</option>
<option value="Pengatur Muda / II.a">Pengatur Muda / II.a</option>
<option value="Pengatur Muda Tk. I / II.b">Pengatur Muda Tk. I / II.b</option>
<option value="Pengatur / II.c">Pengatur / II.c</option>
<option value="Pengatur Tk. I / II.d">Pengatur Tk. I / II.d</option>
<option value="Penata Muda / III.a">Penata Muda / III.a</option>
<option value="Penata Muda Tk. I / III.b">Penata Muda Tk. I / III.b</option>
<option value="Penata / III.c">Penata / III.c</option>
<option value="Penata Tk. I / III.d">Penata Tk. I / III.d</option>
<option value="Pembina / IV.a">Pembina / IV.a</option>
<option value="Pembina Tk. I / IV.b">Pembina Tk. I / IV.b</option>
<option value="Pembina Utama Muda / IV.c">Pembina Utama Muda / IV.c</option>
<option value="Pembina Utama Madya / IV.d">Pembina Utama Madya / IV.d</option>
<option value="Pembina Utama / IV.e">Pembina Utama / IV.e</option>
<option value="PTT">PTT</option>
</select>
</td>
</tr>

<tr>
<td>Jabatan</td>
<td>:</td>
<td><input name="jabatan" type="text" id="jabatan" size="50" maxlength="50"></td>
</tr>
<tr>
<td>Instansi</td>
<td>:</td>
<td><input name="instansi" type="text" id="instansi" size="70" maxlength="70">
</td>
</tr>

<tr>
<td>Jenis Diklat</td>
<td>:</td>
<td><select name="jenis_diklat" size="1">
<option selected value="-">--- Pilih Salah Satu ---</option>
<option value="Diklatpim Tk. I">Diklatpim Tk. I</option>
<option value="Diklatpim Tk. II">Diklatpim Tk. II</option>
<option value="Diklatpim Tk. III">Diklatpim Tk. III</option>
<option value="Diklatpim Tk. IV">Diklatpim Tk. IV</option>
<option value="Diklat Prajabatan CPNSD">Diklat Prajabatan CPNSD</option>
<option value="Diklat Manajemen Kepegawaian">Diklat Manajemen Kepegawaian</option>
<option value="Diklat Bendahara Pengeluaran">Diklat Bendahara Pengeluaran</option>
<option value="Diklat Pejabat Penatausahaan Keuangan">Diklat Pejabat Penatausahaan Keuangan</option>
<option value="Pelatihan / Orientasi PTT">Pelatihan / Orientasi PTT</option>
</select>
</td>
</tr>
<tr>
<td>Berkas Diklat</td>
<td>:</td>
<td><input type="file" name="doc" id="berkas"></td>
</tr>
<tr>
<td colspan="3" align="center"><input name="fok" type="submit" id="fok" value="OK">
<input name="fulang" type="reset" id="fulang" value="Ulangi">
<input name="fulang2" type="button" id="fulang2" value="Batal" onClick="javascript:history.back()"></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
simpan-data.php
<?
include "koneksi.php";
$no_sertifikat=$_POST;
$nip=$_POST;
$nama=$_POST;
$tempat_lahir=$_POST;
$tanggal_lahir = $_POST."-".$_POST."-".$_POST;
$jk=$_POST;
$pangkat=$_POST;
$jabatan=$_POST;
$intansi=$_POST;
$jenis_diklat=$_POST;
if (empty($no_sertifikat))
{
die("Isikan Nomor Sertifikat Diklat!");
}
elseif(empty($nip))
{
die("Isikan NIP!");
}
else
{
$cekdata="select id from pegawai where id='$id'";
$ada=mysql_query($cekdata) or die(mysql_error());
if(mysql_num_rows($ada)>0)
{ die("Nomor Sertifikat telah Terdaftar!"); }
else
{
if (isset($_POST) && isset($_FILES)) {
$dir = './berkas/';
$file = $_FILES;
$name = $_FILES;
$info = pathinfo($name);
$size = filesize ($file);
if ($size > 1000000){
exit('UKURAN FILE TERLALU GEDHE, CARI NYANG LAEN');
}
$ext = $info;
if(($ext == 'pdf') || ($ext == 'rar')){
if (!is_uploaded_file($file)) {
exit('GAG ADA FILE...');
}
if (!move_uploaded_file($file, $dir.$name)) {
echo 'Unable to upload file';
} else {
echo 'FILE BERHASIL DI-UPLOAD';
}
} else {
echo('CUMAN BOLEH UPLOAD PDF atau RAR');
}
}
mysql_query("insert into pegawai(no_sertifikat,nip,nama,tempat_lahir,tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas)" .
"values('$no_sertifikat','$nip','$nama','$tempat_lahir','$tanggal_lahir','$jk','$pangkat','$jabatan','$intansi','$jenis_diklat','$berkas')") or die(mysql_error());
echo "Berhasil";
header("location:laporan-data-pegawai.php");
} //end if terdaftar
}
?>

laporan-data-pegawai.php
<html>
<head>
<title>Laporan Data Pegawai</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h3 align="center" class="telah">Data Pegawai Yang Telah Diklat</h3>
<form action="" method="get" name="FCari" id="FCari">
Cari NIP /Nama
<input name="txtcari" type="text" id="txtcari" size="20" maxlength="30" value="<?php echo $_GET?>">
<input type="submit" name="Submit" value="Cari">
</form>
<p align="left">
<span class="gabung"><a href="index.php">MENU UTAMA</a>&nbsp;
<a href="input-pegawai.php">INPUT DATA</a></span>
</p>
<form name="FLaporan" method="post" action="delete-banyak.php" onSubmit="return confirm('Hapus data terpilih?')">
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td align="center">&nbsp;</td>
<td >Nomor Sertifikat</td>
<td>NIP</td>
<td >Nama</td>
<td >Tempat Lahir</td>
<td >Tanggal Lahir</td>
<td >Jenis Kelamin</td>
<td >Pangkat</td>
<td >Jabatan</td>
<td >Instansi</td>
<td >Jenis Diklat</td>
<td >Berkas</td>
<td >Lanjut</td>
</tr>
<?
include "koneksi.php";
$query=mysql_query ("select * from pegawai", $koneksi) or die (mysql_error());
$jumlah = mysql_num_rows($query);
echo "Jumlah Data Terentry : $jumlah";
$txtcari=$_GET;
if(isset($txtcari))
{
$myquery="select id,nip,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas from pegawai where nip='$txtcari' or nama LIKE '%$txtcari%'";
}
else
{
$myquery="select id,nip,nama,tempat_lahir, DATE_FORMAT(tanggal_lahir, '%d-%m-%Y') as tanggal_lahir,jk,pangkat,jabatan,instansi,jenis_diklat,berkas from pegawai";
}
$daftarpegawai=mysql_query($myquery) or die (mysql_error());
while($dataku=mysql_fetch_object($daftarpegawai))
{
?>
<tr>
<td align="center">
<input type="checkbox" name="item[]" id="item[]" value="<?php echo $dataku->id?>" /></td>
<td ><?php echo $dataku->id?></td>
<td ><?php echo $dataku->nip?></td>
<td ><?php echo $dataku->nama?></td>
<td ><?php echo $dataku->tempat_lahir?></td>
<td ><?php echo $dataku->tanggal_lahir?></td>
<td ><?php echo $dataku->jk?></td>
<td ><?php echo $dataku->pangkat?></td>
<td ><?php echo $dataku->jabatan?></td>
<td ><?php echo $dataku->instansi?></td>
<td ><?php echo $dataku->jenis_diklat?></td>
<td> <?php echo $dataku->berkas?></td>

<td align="center"><a href="koreksi-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Koreksi</a></td>

<td align="center"><a href="hapus-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Hapus</a></td>
<td align="center"> <a href="download-data-pegawai.php?no_sertifikat=<?php echo $dataku->id?>">Download</a></td>
</tr>
<?
}
?>
</table>
<input name="btnHapus" type="submit" value="Delete" onsubmit="return confirm ('hapus data yang dipilih')">
</form>
</body>
</html> nah data berkas yang bertife pdf tidak masuk/tampil di tabel laporan-data-pegawai.php.
gimana tu master-master sekalian??????...............