0% found this document useful (0 votes)
13 views2 pages

Contoh Script CRUD PHP

Uploaded by

pcabikkapas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Contoh Script CRUD PHP

Uploaded by

pcabikkapas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

KONEKSI.

PHP
<?php
mysql_connect("localhost","root","rumahkuok");
mysql_select_db("db_kontak");
?>

[Link]
<html>
<head></head>
<body onload="[Link]();">
<form method="post" action="[Link]" name="home">
<table border="0" align="center" width="350">
<tr bgcolor="#99FF00"><td colspan="3"><b>TAMBAH KONTAK BARU</b></td></tr>
<tr><td>Nama Lengkap</td><td align="center">:</td><td align="right"><input type="text" size="35"
id="nama" name="nama" required="required"/></td></tr>
<tr><td>[Link]</td><td align="center">:</td><td align="right"><input type="text" size="35"
id="kontak" name="kontak" required="required"/></td></tr>
<tr><td colspan="3"><input type="submit" name="kirim" id="kirim" value="SIMPAN"><input type="reset"
name="reset" id="reset" value="ULANG" onClick="[Link]();"></td></tr>
</table><br />
<!--Menampilkan data dengan tabel-->
<table border="1" align="center" width="350">
<?php
include "[Link]";
$sql=mysql_query("select * from tb_kontak");
echo "<thead><th>No.</th><th>Nama Lengkap</th><th>[Link]</th><th>Panel</th></thead>";
while ($tampil=mysql_fetch_array($sql))
echo "
<tr>
<td>$tampil[nomor]</td>
<td>$tampil[nama]</td>
<td>$tampil[kontak]</td>
<td><a href=[Link]?m=$tampil[nomor]>edit</a> | <a href=[Link]?m=$tampil[nomor]
onclick=\"return confirm('Hapus $tampil[nama] ?')\">hapus</a></td>
</tr>";
?>
</table>
</form>
</body>
</html>

[Link]
<?php
include "[Link]";
$nama=$_POST['nama'];
$kontak=$_POST['kontak'];
mysql_query("insert into tb_kontak values('','$nama','$kontak')");
echo "<meta http-equiv=refresh content=0;url=[Link]>";
?>

[Link]
<style>
a {text-decoration:none;}
a:hover {text-decoration:none;}
</style>
<?php
include "[Link]";
$nomor=$_GET['m'];
$edit=mysql_fetch_array(mysql_query("select * from tb_kontak where nomor=$nomor"));
?>
<html>
<head></head>
<body onload="[Link]();">
<form method="post" action="[Link]" name="updatehome">
<table border="0" align="center" width="350">
<tr bgcolor="#99FF00"><td colspan="3"><b>EDIT KONTAK</b></td></tr>
<tr><td colspan="3"><input type="hidden" name="nomor" id="nomor" value="<?php echo
"$edit[nomor]";?>" /></td></tr>
<tr><td>Nama Lengkap</td><td align="center">:</td><td align="right"><input type="text" size="35"
id="nama" name="nama" required="required" value="<?Php echo "$edit[nama]";?>"/></td></tr>
<tr><td>[Link]</td><td align="center">:</td><td align="right"><input type="text" size="35"
id="kontak" name="kontak" required="required" value="<?Php echo "$edit[kontak]";?>"/></td></tr>
<tr><td colspan="3"><input type="submit" name="update" id="update" value="UPDATE"><a
href="[Link]"><input type="button" name="kembali" id="kembali" value="KEMBALI"/></a></td></tr>
</table><br />
</form>
</body>
</html>

[Link]
<?php
include "[Link]";
$nomor=$_POST['nomor'];
$nama=$_POST['nama'];
$kontak=$_POST['kontak'];
mysql_query("update tb_kontak set nama='$nama', kontak='$kontak' where nomor='$nomor'");
echo "<meta http-equiv=refresh content=0;url=[Link]>";
?>

[Link]
<?Php
include "[Link]";
$nomor=$_GET['m'];
mysql_query("delete from tb_kontak where nomor='$nomor'");
echo "<meta http-equiv=refresh content=0;url=[Link]>";
?>

You might also like