Pertama membuat file Index.php simpan di folder bukutamu,
Index.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title>Guest Book</title> </head> <body> <pre> <h2>Signup Guestbook </h2> <hr size=1> <form name="tamu" method="post" action="simpan.php"> Name : <input type="text" name="name"><br> E-Mail : <input type="text" name="email"><br> Address : <input type="text" name="alamat"><br> City : <input type="text" name="kota"><br> Message : <br><textarea name="msg"></textarea><br> <input type="submit" name="submit" value="Send"><input type="reset" name="reset" value="Reset"> </form> </body> </html>
Lalu yang kedua membuat
Kedua membuat file Simpan.php simpan di folder bukutamu,Simpan.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title>Simpan Data</title> </head> <body> <?php $nama=$_POST['name']; $email=$_POST['email']; $alm=$_POST['alamat']; $kota=$_POST['kota']; $msg=$_POST['msg']; $koneksi=mysql_connect("localhost","root",""); mysql_select_db("buku_tamu"); $proses="INSERT INTO tamu(name,email,address,city,msg) VALUES('$nama','$email','$alm','$kota','$msg')"; $hasil=mysql_query($proses,$koneksi); echo "<font color=red size=5>Buku Tamu BERHASIL Diisi</font>"; ?> <br> <a href="tampil.php"><h3>Lihat Buku Tamu</h3></a> </body> </html>Untuk menampilkan file nya dengan membuat file,
Ketiga membuat tampil Index.php simpan di folder bukutamu, untuk menampilkan isi buku tamunya
Tampil.php<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head> <title>BUKU TAMU</title> </head> <body> <pre> <h1>BUKU TAMU</h1> <a href="index.php"> <-- Kembali ke Form Buku Tamu</a> <hr size=1> <?php $koneksi=mysql_connect("localhost","root",""); mysql_select_db("buku_tamu"); $sql=mysql_query("SELECT * FROM tamu", $koneksi); while($data=mysql_fetch_array($sql)) { $id=$data['id']; $name=$data['name']; $email=$data['email']; $alm=$data['address']; $city=$data['city']; $msg=$data['msg']; echo "No : $id<br>"; echo "Nama : $name<br>"; echo "E-Mail : $email<br>"; echo "Alamat : $alm, $city<br>"; echo "Pesan : $msg<br><hr size=1>"; } ?> </body> </html>
0 komentar:
Posting Komentar