Rabu, 17 Desember 2008

Membuat Guestbook dengan PHP

Bagi anda yang ingin belajar PHP, maka anda bisa mencoba membuat sebuah program sederhana yaitu buku tamu (guestbook). berikut langkah-langkahnya :

1. Buatlah database “guesbook”



CREATE TABLE `guestbook` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default ”,
`email` varchar(65) NOT NULL default ”,
`comment` longtext NOT NULL,
`datetime` varchar(65) NOT NULL default ”,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

2. Buat file guestbook.php







Test Sign Guestbook





























Name:
Email:
Comment:
  






View Guestbook


3. Buatlah file addguestbook.php



$host=”localhost”; // Host name
$username=”"; // Mysql username
$password=”"; // Mysql password
$db_name=”test”; // Database name
$tbl_name=”guestbook”; // Table name



// Connect to server and select database.
mysql_connect(”$host”, “$username”, “$password”)or die(”cannot connect server “);
mysql_select_db(”$db_name”)or die(”cannot select DB”);

$datetime=date(”y-m-d h:i:s”); //date time

$sql=”INSERT INTO $tbl_name(name, email, comment, datetime)VALUES(’$name’, ‘$email’, ‘$comment’, ‘$datetime’)”;
$result=mysql_query($sql);

//check if query successful
if($result){
echo “Successful”;
echo “
”;
echo “View guestbook”; // link to view guestbook page
}

else {
echo “ERROR”;
}

mysql_close();
?>

4. Buat file viewguestbook.php





View Guestbook | Sign Guestbook





$host=”localhost”; // Host name
$username=”"; // Mysql username
$password=”"; // Mysql password
$db_name=”test”; // Database name
$tbl_name=”guestbook”; // Table name

// Connect to server and select database.
mysql_connect(”$host”, “$username”, “$password”)or die(”cannot connect server “);
mysql_select_db(”$db_name”)or die(”cannot select DB”);

$sql=”SELECT * FROM $tbl_name”;
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
?>






























ID:
Name:
Email:
Comment:
Date/Time :



}
mysql_close(); //close database
?>

ayo semangat .....Ganbate kudasai!!!!!
!!

Membuat Hit Counter

Mau tau ??

1.Login Ke Blog Anda lalu masuk ke tata letak
2.Klik tambah gadtget lalu pilih HTML , lalu pilih tambah
3.Buka new tab lalu buka http://www.hit-counts.com/ lalu muncul kayak gini..



4.Pilih style counter hit lalu isi form di bawahnya



5.Centang term and conditions
6.klik generate
7.Copy script hit counter ke windows HTML
8.Klik simpan...
9.Tara...maka muncullah hit counter anda..

Contoh :






watashi wa sumimasen

ganbate kudasai...