Tabel Mahasiswa |
Gambar 1.0 Ketika Button Simpan Diclick Maka Akan Tampil Seperti Gambar 2.0 |
Gambar 2.0 Ketika Click "Lihat Data Mahasiswa" Maka Akan Tampil Seperti Gambar 3.0 |
Gambar 3.0 Ketika Click "Kembali Input Data" Maka Akan Tampil Seperti Gambar 1.0 |
NB : Buatlah Database Terlebih Dahulu, Setelah Itu Buat Lah Tabel Seperti Gambar "Tabel Mahasiswa".
Coding/Listing Gambar 1.0 (Simpan Dengan Nama latihan13.html) :
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Latihan 13</title>
</head>
<body style="background-image:url(http://localhost/Adam/Background%20Blogger/bg2.jpg)">
<form action="simpan.php" method="post" enctype="multipart/form-data">
<font color="red" face="Papyrus"><center><h1>Input Data Mahasiswa</center></h1></font>
<hr width=100% size=4 color="green" />
<pre>
Nim : <input type="text" size=8 name=nim>
Nama : <input type="text" size=35 name=nama>
Alamat : <input type="text" size=40 name=alamat>
Telepon : <input type="text" size=15 name=telp>
<input type="submit" value=Simpan><input type="reset" value=Batal>
</form>
</body>
</html>
Coding/Listing Gambar 2.0 (Simpan Dengan Nama simpan.php) :
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Latihan 13</title>
</head>
<body style="background-image:url(http://localhost/Adam/Background%20Blogger/bg2.jpg)">
<?
$koneksi=mysql_connect("localhost","root","password");
mysql_select_db("kampus");
$proses="INSERT INTO mahasiswa(nim,nama,alamat,telp)
VALUES('$nim','$nama','$alamat','$telp')";
$hasil=mysql_query($proses,$koneksi);
?>
<font color="red" face="Papyrus"><center><h1>Data Mahasiswa</center><h1></font>
<hr width=100% size=4 color="green" />
<font color="blue" size=5 face="Times New Roman">Data Berhasil Disimpan</font>
<br>
<h3><font align="left"><a href="tampil_mahasiswa.php">Lihat Data Mahasiswa</a></h3></font>
</body>
</html>
Coding/Listing Gambar 3.0 (Simpan Dengan Nama tampil_mahasiswa.php) :
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Latihan 13</title>
</head>
<body style="background-image:url(http://localhost/Adam/Background%20Blogger/bg2.jpg)">
<font face="Papyrus" color="red"><h1><center>Tabel Data Mahasiswa</center></h1></font>
<hr width=100% size=4 color="blue" />
<br>
<table width="500" border="1" align="center">
<tr>
<th colspan="4" scope="col">Tampil Data Mahasiswa</th>
</tr>
<tr>
<td>Nim</td>
<td>Nama</td>
<td>Alamat</td>
<td>Telepon</td>
</tr>
<?php
$koneksi=mysql_connect("localhost","root","password") or die("Koneksi Gagal".mysql_error());
if($koneksi){ mysql_select_db("kampus",$koneksi) or die("Database Gagal Dibuka".mysql_error());
$sql=mysql_query("SELECT * FROM mahasiswa",$koneksi) or die("Query Gagal".mysql_error());
while($data=mysql_fetch_array($sql)){
?>
<tr>
<td><?php echo $data['nim'];?></td>
<td><?php echo $data['nama'];?></td>
<td><?php echo $data['alamat'];?></td>
<td><?php echo $data['telp'];?></td>
</tr>
<?php }} ?>
</table>
<center><h3><a href="latihan13.html">Kembali Input Data</a></center></h3>
</body>
</html>