makalah php
TRANSCRIPT
![Page 1: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/1.jpg)
MAKALAH PHPSource Code Sewa VCD
Disusun oleh :
Ilham MuhammadXI RPL 1
20
PROGRAM KEAHLIAN
REKAYASA PERANGKAT LUNAK
ANGKATAN XVII
![Page 2: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/2.jpg)
SMK TELKOM SANDHYPUTRA PURWOKERTO2010 / 2011
1. conn.php
<?php mysql_connect('localhost','root','') or die('cannot connect to server'); mysql_select_db('sewa') or die('cannot connect to database');?>
2. Index.php (form input)a. Design
b. Script
<html><head>
<title>Toko Rental</title></head>
<body><h1 align="center">Toko Rental VCD/DVD/HD-DVD/BD</h1><hr width="800"><form action='input.php' method='POST' name='input'><table align=center>
<tr><td>Judul</td><td>:</td><td><input type='text' name='judulfilm' size='25'></td>
</tr><tr>
<td>Kategori</td><td>:</td><td><input type='text' name='kategori' size='15'></td>
</tr><tr>
<td>Harga Sewa</td><td>:</td><td><input type='text' name='hargasewa' size='10'></td>
![Page 3: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/3.jpg)
</tr><tr>
<td>Jumlah</td><td>:</td><td><input type='text' name='jumlah' size='5'></td>
</tr><tr>
<td colspan=3 align=center><input type='submit' value='simpan'> <input type='reset' value='clear'></td>
</tr></table></form><center><form action='lihat.php'><input type='submit' value='Lihat Data'></form></center>
</body></html>
3. Lihat.php (form lihat data)a. Design
b. Script
<html><head>
<title>Daftar Film</title></head>
<body><h1 align="center">Daftar Film Yang Tersedia</h1><hr width="800"><form action='' method='GET'>
<table align=center border=1><th>Kode Film</th><th>Judul Film</th><th>Kategori</th><th>Harga Sewa</th><th>Jumlah</th>
![Page 4: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/4.jpg)
<th>Action</th>
<?phpinclude('conn.php');$query="Select * from vcd order by kodefilm";$myquery=mysql_query($query);
while($data=mysql_fetch_array($myquery)){echo "<tr align=center>
<td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>
<a href='proses.php?proses=edit&kode=$data[0]'>Edit</a> <a href='proses.php?proses=delete&kode=$data[0]'>Delete</a></td>
</tr>";}
?></table></form><center><form action="index.php">
<input type="submit" value="Halaman Utama"></form></center>
</body></html>
4. Proses.phpa. Design (Form edit)
b. Script Form Edit & Delete
<?phpinclude('conn.php');
$proses=$_GET['proses'];$kode=$_GET['kode'];
![Page 5: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/5.jpg)
if($proses=='edit'){$query="select * from vcd where kodefilm=".$kode;$myquery=mysql_query($query);
while($data=mysql_fetch_array($myquery)){echo "<h1 align='center'>Menyunting Data Film</h1><hr width='800'><form action='edit.php' method='POST'>
<table align='center'><tr>
<td>Kode Film</td><td>:</td><td><input type='text' name='kodefilm'
size='25' value='$data[0]'></td><tr>
<td>Judul Film</td><td>:</td><td><input type='text' name='judulfilm'
size='25' value='$data[1]'></td></tr><tr>
<td>Kategori</td><td>:</td><td><input type='text' name='kategori'
size='15' value='$data[2]'></td></tr><tr>
<td>Harga Sewa</td><td>:</td><td><input type='text'
name='hargasewa' size='15' value='$data[3]'></td></tr><tr>
<td>Jumlah</td><td>:</td><td><input type='text' name='jumlah'
size='15' value='$data[4]'></td></tr><tr>
<td colspan='3' align='center'><input type='submit' value='simpan'></td>
</table></form>";}
}else if($proses==delete)
{
![Page 6: Makalah PHP](https://reader036.vdocuments.pub/reader036/viewer/2022082408/5447f5e5afaf9f35088b4745/html5/thumbnails/6.jpg)
$query="delete from vcd where kodefilm=".$kode;mysql_query($query);Header("Location:lihat.php");}
?>
5. Edit.php (Update Data)
<?phpinclude('conn.php');
$kodefilm=$_POST['kodefilm'];$judulfilm=$_POST['judulfilm'];$kategori=$_POST['kategori'];$hargasewa=$_POST['hargasewa'];$jumlah=$_POST['jumlah'];
$query="update vcd set judulfilm='$judulfilm', kategori='$kategori', hargasewa='$hargasewa', jumlah='$jumlah' where kodefilm='$kodefilm'";
if(!mysql_query($query)){
echo 'Gagal menupdate data<br/>'.mysql_error();}
else{
echo "<script>alert('Data berhasil di-update');document.location.href='index.php'</script>";
}?>