The Making of Guest Book in Web Application Using PHP

Recently, i have just learned about web programming. Actually, there are several items that we must know to build or create a good website. The first is HTML code, the second one is PHP structure. CSS , javascript, jquery and etc.

Alhamdulillah, only in several days, i already finished them.but, even though i think it is already good enough.

first of all, we have to prepare the form. I mean guest book form. And then make file to process data which is already sent named savefile.php.. and the last task is put the file into guest_log.txt”. Here is the first step.

<title>Buku Tamu</title>
function validasi(){
var nama=form.txtnama.value;
var emailregex=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var email=form.txtemail.value;
alert('nama harus diisi');
return false;
alert("alamat email tidak valid");
return false;
font-family:Verdana, Arial, Helvetica, sans-serif;
<h1 align="center">Selamat Datang</h1>
<table align="center" border="1" cellpadding="20">
<table border="0" cellpadding="5">
<form method="post" action="save.php" name="form" id="form" >
<td align="right">Nama :</td><td><input type="text" name="txtnama" id="txtnama" onBlur="return validasi()"/></td>
<td align="right">Alamat :</td><td><input type="text" name="txtalamat"/></td>
<td align="right">E- mail :</td><td><input type="text" name="txtemail" onBlur="return validasi()"/></td>
<td align="right">Website/ Blog :</td><td><input type="text" name="txtblog"/></td>
<td align="right">Komentar :</td><td><textarea name="txtkomentar"></textarea></td>
<td align="right"><input type="submit" value="Save" name="btsave" /></td><td><input type="reset" value="Reset"/></td>

alright, if you check out in your browser, the preview is almost like this one,it means that you have been sucessfull to make the form, and the next, is to send the form using method post into file save.php.But, before that, we have to make file bukutamu.txt in the same directory of the program.

here is the code for saving data of guests :

echo "nama kosong harus diisi";
$simpan="Nama = $nama \n alamat=$alamat \n email=$email \n blog=$blog \n komentar = $komentar \n";
echo "file is found";
echo "file not found";

Inside the code above, there are several functions for file operation such as fopen, feof, fgets and etc. that’s why in this program doesn’t need database as storage. here is the result of the program :

good luck 🙂



Tagged: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: