Tutorial, Tutorial, & Tutorial

December 11, 2008

Membuat Kategori

Filed under: Script — catroc @ 11:28 pm

Berikut adalah contoh script membuat kategori, bisa di download:
1. Copy dan Simpan script berikut dalam bentuk html (kategori.html)

<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<p align=”left”>Tambah Kategori</p>
<form action=”tambahkategori.php” method=”post”>
<table width=”75%” border=”3″>

<tr>
<td width=”22%”>Kategori</td>
<td width=”2%”>&nbsp;</td>
<td width=”76%”><input type=”text” name=”isi” size=”30″></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input type=”submit” name=”Submit” value=”OK”></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
</form>
</body>
</html>

2. Buatlah database, mis nama database dbku, dengan nama table kategori, menggunakan phpmyadmin

3. Buatlah file koneksi.inc.php, script programnya:

<?php
//include “koneksi.inc.php”;
$server=”localhost”;
$user=”root”;
$pass=”";
//buka koneksi
$konek=mysql_connect($server,$user,$pass);
//jika benar buka database
if($konek){
mysql_select_db(“dbku”);
//echo “Connection succes!”;
}else{
echo “Sorry, connection failed!”;
}
?>

4. Tambahkan file isikategori.php, script programnya:
<?php
include “koneksi.inc.php”;
$sql=”INSERT INTO kategori set isi=’$isi’”;
if(!empty($isi)){
$hasil=mysql_query($sql);
}else{
echo “Maaf,anda harus mengisikan kategori!”;
}
if($hasil){
//header(“location:tambahkategori.html”);
echo “Sukses!<br>”;
echo “<a href=tambahkategori.html>Lagi</a>”;
}else{
echo”tambah kategori gagal!”;
echo “<a href=tambahkategori.html>Ulangi</a>”;
}
?>

Setelah itu masuklah ke browser dan cek (http://localhost/kategori/tambahkategori.html) dan isi dengan sembarang kategori. Mis Berita Terbaru

5. Klik OK, jika tidak masalah maka akan konfirmasi sukses.
6. Silahkan dimodifikasi sendiri. OK teman

1 Comment »

  1. very good

    Comment by catroc — December 11, 2008 @ 11:31 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.