0% found this document useful (0 votes)
31 views5 pages

Tugas 8

This document contains PHP code for a simple employee data entry application. It includes code for connecting to a MySQL database, displaying existing employee records in a table, adding new records, and providing a form to submit new data. The code includes separate files for the database connection, displaying records, adding new records, and a main form to submit data. Users can view existing data, submit new data via a form, which then inserts the data into the database table.

Uploaded by

Helmi Foto Copy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Tugas 8

This document contains PHP code for a simple employee data entry application. It includes code for connecting to a MySQL database, displaying existing employee records in a table, adding new records, and providing a form to submit new data. The code includes separate files for the database connection, displaying records, adding new records, and a main form to submit data. Users can view existing data, submit new data via a form, which then inserts the data into the database table.

Uploaded by

Helmi Foto Copy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NIM

: 11.240.0026

NAMA

: HUSNUL HELMI

Tugas 8

Lihat.php
<?php
include("koneksi.php");

$x="SELECT * FROM jabatan_fungsional";


$z=mysql_query($x);
echo "<table border='1'>";
echo "<tr><td>No</td><td>kode</td><td>jenis</td><td>nip</td><td>gol</td><td>tunj</td></tr>";
$no=1;
while($y=mysql_fetch_row($z)){

echo "<tr><td>".$no."</td>";
echo "<td>".$y[0]."</td>";
1
11.240.0026 Husnul Helmi

echo "<td>".$y[1]."</td>";
echo "<td>".$y[2]."</td>";
echo "<td>".$y[3]."</td>";
echo "<td>".$y[4]."</td></tr>";
$no++;
}

echo "</table>";
echo "<br><br>";
echo "<a href='form.php'> kembali ke form</a>";
?>
Simpan.php
<?php
include("koneksi.php");

$kode=$_POST["txtkode"];
$jenis=$_POST["jenis"];
$nip=$_POST["txtnip"];
$gol=$_POST["txtgol"];
$tunj=$_POST["txttunj"];

$a="INSERT INTO jabatan_fungsional values('$kode', '$jenis', '$nip', '$gol', '$tunj')";


mysql_query($a);

include("lihat.php");

2
11.240.0026 Husnul Helmi

echo "</table>";
?>
Form.php
<form name="a" method="post" action="simpan.php">
<table>
<caption>BIODATA</caption>
<tr>
<td>Kode</td>
<td>:</td>
<td><input type="text" name="txtkode" /></td>
</tr>
<tr>
<td>Jenis</td>
<td>:</td>
<td><select name="jenis" >
<option value="Kepala">Kepala</option>
<option value="Sekretaris">Sekretaris</option>
<option value="Kabid">Kabid</option>
<option value="Kasubid">Kasubid</option>
</select>
</td>
</tr>
<tr>
<td>Nip</td>
<td>:</td>
<td><input type="text" name="txtnip" /></td>
3
11.240.0026 Husnul Helmi

</tr>
<tr>
<td>Golongan</td>
<td>:</td>
<td><input type="text" name="txtgol" /></td>
</tr>
<tr>
<td>Tunj</td>
<td>:</td>
<td><input type="text" name="txttunj" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Simpan"
/>

</td>
</tr>
</table></form>
<a href="lihat.php"> tampilkan data</a>
Index.php
<?php
include("form.php");
?>
Koneksi.php

<?php
//konfigurasi nama host, nama user dan password
4
11.240.0026 Husnul Helmi

$Host = 'localhost';
$User = 'root';
$Pass = '';

//membangun koneksi. Bagian or die akan dijalankan jika koneksi gagal dilakukan
$Hasil = mysql_connect($Host,$User,$Pass) or die ("koneksi gagal !!");

$Namadb = '45';

//memilih database
$db = mysql_select_db($Namadb);

?>

5
11.240.0026 Husnul Helmi

You might also like