Difference between revisions of "PHP: Membuat Guest Book Sederhana"

From OnnoWiki
Jump to navigation Jump to search
Line 27: Line 27:
 
  PRIMARY KEY (`id`)
 
  PRIMARY KEY (`id`)
 
  ) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
  ) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 +
 +
 +
==guestbook.php==
 +
 +
 +
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
 +
<tr>
 +
<td><strong>Buku Tamu </strong></td>
 +
</tr>
 +
</table>
 +
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
 +
<tr>
 +
<form id="form1" name="form1" method="post" action="addguestbook.php">
 +
<td>
 +
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
 +
<tr>
 +
<td width="117">Nama</td>
 +
<td width="14">:</td>
 +
<td width="357"><input name="name" type="text" id="name" size="40" /></td>
 +
</tr>
 +
<tr>
 +
<td>Email</td>
 +
<td>:</td>
 +
<td><input name="email" type="text" id="email" size="40" /></td>
 +
</tr>
 +
<tr>
 +
<td valign="top">Komentar</td>
 +
<td valign="top">:</td>
 +
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea></td>
 +
</tr>
 +
<tr>
 +
<td>&nbsp;</td>
 +
<td>&nbsp;</td>
 +
<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
 +
</tr>
 +
</table>
 +
</td>
 +
</form>
 +
</tr>
 +
</table>
 +
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
 +
<tr>
 +
<td><strong><a href="viewguestbook.php">Lihat Buku Tamu</a> </strong></td>
 +
</tr>
 +
</table>

Revision as of 13:15, 9 May 2018

Sumber:

http://www.phpeasystep.com/phptu/15.html
http://www.phpeasystep.com/workshopview.php?id=16


Yang perlu dibuat

  • Table "guestbook" in database "test".
  • guestbook.php.
  • addguestbook. php.
  • viewguestbook.php


Membuat tabel guestbook

mysql -u root -p123456
create database test;
use test;
grant ALL on root.* to test@localhost;
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`)
) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


guestbook.php

Buku Tamu
<form id="form1" name="form1" method="post" action="addguestbook.php"> </form>
Nama : <input name="name" type="text" id="name" size="40" />
Email : <input name="email" type="text" id="email" size="40" />
Komentar : <textarea name="comment" cols="40" rows="3" id="comment"></textarea>
    <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" />
<a href="viewguestbook.php">Lihat Buku Tamu</a>