form edit

<html>
<head>
<title>Edit pegawai</title>
</head>

<body>
<table border=”1″ width=”80%” height=”600″ align=”center” frame=”above”>”);
<tr>
<td height=”150″ border=”1″ width=”80%” colspan=”2″><img src=”hearder_2.jpg”  height=”150″ width=”1200″></td>
</tr>

<tr>

<td height=”1″ border=”1″ valign=”justify” bgcolor=”#6699CC”>
<table align=”left” border=”0″ valign=”top” bgcolor=”#6699CC” frame=”above”>
<tr>
</tr>
</table>
</td>
</tr>

<tr>
<td border=”1″ height=”80%” width=”90%” align=”left” valign=”top”>

<?php
require_once “koneksi_karyawan.php”;
require_once “format_tanggal.php”;

$nip=$_GET[‘kode’];

print(“<form action=\”edit_query.php\” method=\”post\”>”);

$sql=”select *from karyawan where nip=’$nip'”;
$hasil=mysql_query($sql,$coba);

$baris=mysql_fetch_row($hasil);

$nip_tampil=$baris[0];
$nama=$baris[1];
$tgl_lahir_my=$baris[2];
$jen_kel=$baris[3];
$dept=$baris[4];

$tgl_lahir=my_ke_tgl2($tgl_lahir_my);

$sql_dep=”select *from depart”;
$hasil_dep=mysql_query($sql_dep,$coba);

while($baris_dep=mysql_fetch_row($hasil_dep)){
$kode_dep=$baris_dep[0];
$nama_dep=$baris_dep[1];

if($kode_dep==$dept) $nama_departemen=”$nama_dep”;
}

if($jen_kel==TRUE) $jen_kel=”pria”;
else $jen_kel=”wanita”;

print(“NIP pegawai        :   <input type=\”text\” name=\”nip_edit\” value=\”$nip\” size=\”30\” maxlenght=\”30\”>”);
print(“<br>”);
print(“Nama Pegawai     :  $nama”);
print(“<br>”);
print(“tanggal lahir    :  $tgl_lahir”);
print(“<br>”);
print(“jenis kelamin    :  $jen_kel”);
print(“<br>”);
print(“Departemen        :  $nama_departemen”);
print(“<br>”);

print(“<br>”);
print(“<left><input typt=\”button\” value=\”      daftar pegawai\” onclick=\”self.history.back()\”></left>”);

print (“<h2 align=\”center\”>Edit Pegawai</h2>”);

print(“<table width=\”64%\” border=\”0\” align=\”center\”>”);
print(“<tr>”);
print(“<td width=\”21%\” align=\”left\” height=\”58\”>NIP pegawai</td>”);
print(“<td width=\”79%\”><input name=\”nip\” size=\”70\” maxlenght=\”70\” type=\”text\”></td>”);
print(“</tr>”);

print(“<tr>”);
print(“<td align=\”left\” height=\”58\”>Nama pegawai</td>”);
print(“<td><input name=\”nama\” size=\”70\” maxlenght=\”70\” type=\”text\”></td>”);
print(“</tr>”);

print(“<tr>”);
print(“<td align=\”left\” height=\”58\”>Jenis kelamin</td>”);
print(“<td><input type=\”checkbox\” value=\”pria\” checked=\”checked\” name=\”jen_kel\”> &nbsp pria</td>”);
print(“</tr>”);

print(“<tr>”);
print(“<td align=\”left\” height=\”58\”>Tanggal lahir</td>”);
print(“<td>”);

require_once “skrip_tanggal.php”;
pilihan_tanggal(10,02,1991);

print(“</td>”);
print(“</tr>”);

print(“<tr>”);
print(“<td align=\”left\” height=\”58\”>Departemen</td>”);
print(“<td>”);

/*$username=”root”;
$pass=””;
$alamat=”localhost”;

$koneksi=mysql_connect($alamat,$username,$pass);
if(!$koneksi) die(“koneksi gagal dilakukan”);

$select=mysql_select_db(“departemen”,$koneksi);
if(!$select) die(“database tidak bisa dipilih”);
*/

$sql=”select *from depart”;
$hasil=mysql_query($sql,$coba);

print(“<select name=\”dep\”>”);
while($baris=mysql_fetch_row($hasil)){
$kode_dep=$baris[0];
$nama_dep=$baris[1];

print(“<option value=\”$kode_dep\”>$nama_dep</option>”);
}
print(“</select>”);

print(“</td>”);
print(“</tr>”);
print(“</table>”);
print(“<center><input type=\”submit\” value=\”ubah\” name=\”buttonubah\”></center>”);
print(“</form>”);

?>

</td>
</table>
<br>

</td>
</tr>
</table>

</body>
</html>

BAGIAN EKSEKUSINYA

<html>
<head>
<title>Edit pegawai</title>
</head>

<body>
<table border=”1″ width=”80%” height=”600″ align=”center” frame=”above”>”);
<tr>
<td height=”150″ border=”1″ width=”80%” colspan=”2″><img src=”hearder_2.jpg”  height=”150″ width=”1200″></td>
</tr>

<tr>

<td height=”1″ border=”1″ valign=”justify” bgcolor=”#6699CC”>
<table align=”left” border=”0″ valign=”top” bgcolor=”#6699CC” frame=”above”>
<tr>
<td border=”1″ width=”100″ height=”52″><a href=”daftar_peg.php”><img src=”button_1.png”  height=”50″ width=”100″></a></td>
<td border=”1″ width=”100″ height=”52″><img src=”button_input.png”  height=”50″ width=”100″></td>
</tr>
</table>
</td>
</tr>

<tr>
<td border=”1″ height=”80%” width=”90%” align=”center” valign=”justify”>

<?php
require_once “koneksi_karyawan.php”;
require_once “format_tanggal.php”;

$nip_edit=$_POST[‘nip_edit’];
$nip=$_POST[‘nip’];

/*
$array[strlen($nip_edit+1)]=$nip_edit;

while($array[$jum]){
if($array[$jum]==”,”){
$hasil=$jum;
print(“$hasil”);
}
$jum++;
}
*/

$nama_edit=$_POST[‘nama’];
$jen_kel_edit=$_POST[‘jen_kel’];
$dep_edit=$_POST[‘dep’];
$nama_tgl=$_POST[‘nama_tanggal’];
$nama_bln=$_POST[‘nama_bulan’];
$nama_thn=$_POST[‘nama_tahun’];

$tgl_lahir_edit=tgl_ke_my($nama_tgl,$nama_bln,$nama_thn);
if($jen_kel_edit==”pria”){
$pria_edit=TRUE;
}
else $pria_edit=FALSE;

$sql_update=”UPDATE karyawan SET nip=’$nip’,nama=’$nama_edit’,tgl_lhr=’$tgl_lahir_edit’,jen_kel=’$pria_edit’,dept=’$dep_edit’  “.
” where nip=’$nip_edit’ “;
$hasil=mysql_query($sql_update,$coba);
if($hasil) print(“<h1>Data $nip_edit dengan nama $nama_edit berhasil di ubah!!!</h1>”);
?>

</td>
</table>
<br>

</td>
</tr>
</table>

</body>
</html>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s