Kategori
PHP

GuestBook Sederhana dengan PHP & Mysql

Studi Kasus : Membuat guestbook sederhana dengan PHP Mysql
Kebutuhan : Webserver Packages, already installed.

Ok, langsung praktik saja.

Step 1 : Persiapkan Database

  1. Buat database dengan nama db_tutorial
  2. Siapkan tabel dengan nama tb_guestbook, dengan struktur tabel seperti gambar dibawah ini.
  3. Done!

Step 2 : Persiapkan Folder Kerja

  1. Buat folder dengan nama tutorphp dalam document root anda
  2. Simpan semua file dalam tutorial ini dalam folder tersebut.

Step 3 : Membuat script koneksi ke Database

  1. Ketikkan script berikut,
    [sourcecode language=”php”]
    <?php
    $host = "localhost";
    $user = "root";//adjust according to your mysql setting
    $pass = ""; //adjust according to your mysql setting, i use no password here
    $dbName = "db_tutorial";
    mysql_connect($host, $user, $pass);
    mysql_select_db($dbName)
    or die ("Connect Failed !! : ".mysql_error());
    ?>
    [/sourcecode]
  2. simpan dengan nama connect.php

Step 4 : Membuat form guestbook

  1. Ketikkan script berikut,
    [sourcecode language=”php”]
    <h1>Guestbook</h1>
    <form method="post" action="savegb.php">
    <table>
    <tr><td>Your Name</td><td></td></tr>
    <tr><td>Your Email</td><td></td></tr>
    <tr><td>Your Comment</td><td><textarea name="comment"></textarea></td></tr>
    <tr><td></td><td></td></tr>
    </table>
    </form>

    [/sourcecode]

  2. simpan dengan nama formguestbook.php

Step 5 : Membuat script pemrosesan dan menampilkan guestbook

  1. Ketikkan script berikut,
    [sourcecode language=”php”]
    <?php
    include ‘connect.php’;

    $name = $_POST[‘name’]; //get the name value from form
    $email = $_POST[‘email’]; //get the email value from form
    $comment = $_POST[‘comment’]; //get the comment value from form

    //query to save to database
    $q1 = "INSERT into tb_guestbook value (”,’$name’,’$email’,’$comment’)";
    $result1 = mysql_query($q1);

    //query to get data from database
    $q2 = ‘SELECT * FROM tb_guestbook order by id desc’;
    $result2 = mysql_query($q2);

    //show the data from database
    while ($record = mysql_fetch_array($result2)) {
    echo "<table>";
    echo "<tr><td>Name</td><td>:</td><td>".$record[‘name’]."</td></tr>";
    echo "<tr><td>Email</td><td>:</td><td>".$record[‘email’]."</td></tr>";
    echo "<tr><td>Comment</td><td>:</td><td>".$record[‘comment’]."</td></tr>";
    echo "</table>";
    echo "<br/>";
    }
    ?>
    [/sourcecode]

  2. simpan dengan nama savegb.php
  3. untuk penjelasan script, lihat komentar pada script 😀

Step 6 : Testing Code

  1. Pergi ke http://localhost/tutorphp/formguestbook.php. Anda akan melihat form seperti dibawah. Isikan guestbook tersebut (misal seperti pada gambar dibawah)
  2. Klik tombol save dan anda akan melihat hasilnya

OK. Haaaaaaaapppy Coding! 😀

Oleh littleflow3r

obviously, a girl. with sweet smile, off course. turning her 21 years trapped on Informatics departement and just started to having some crush with it lately. she uses wordpress. she loves php. she loves to satisfied her shopping hobbies just via looking around in online shop. oh yeah, she got an A for her english subject^^

35 replies on “GuestBook Sederhana dengan PHP & Mysql”

Exactly what are the Most Essential Characteristics of the Best Courting Internet site?
Picking the best courting site on the net isn’t always as easy as it may sound. Each online dating internet site https://blogcitynews.com has many different capabilities that each person might want. So how do you find the best go with and what features are crucial to you?

Internet dating sites like MySlate, Go with, Fast Singles, and Dater do each of the do the job. They bring together members of varied qualification and find suitable singles. It’s really much like searching in the woods. You have to make use of intuition and knowledge of the ground to get the appropriate match.

Online dating services websites will typically make use of an algorithm formula to fit you with potential complements based on stuff like your sex, grow older, size, excess weight, faith, training, ethnicity, plus more. For those who have been out with a man that is over weight, your web account might read “Not just a Health Nut,” or you could find an overweight person messaging you consistently. Every person’s online information can vary. It’s information on getting yourself with your customers boots and which makes them comfy.

[url=http://multfilms.tv/]Мультфильмы[/url]

[url=http://multfilms.tv/multfilm.php?id=1664]Мультфильм Ну погоди[/url]

[url=http://multfilms.tv/multfilm.php?id=352]Смотреть онлайн мультфильм Вини пух[/url]

[url=http://multfilms.tv/multfilm.php?id=857]мультфильм золушка смотреть[/url]

kalo bikin tutor yg lengkap mas, kaya ga niat ckckck, kasihan yg pemula di bikin pusing, ngasih ilmu jgn setengah-setengah aku tau itu ada scipt yg kurang.. kebangetan juga nih kalo post ku ini ga di accept wkakwk
(lmao)

untuk script formguestbook.php sepertinya masih belum lengkap, karna hanya menampilkan satu form saja, dan tombol submitnya juga belum ada, mungkin bisa menggunakan script dibawah ini untuk lebih lengkapnya:
===================================================

Guestbook

Your Name:
:

Your Email
:

Your Comment
:

:

semoga berhasil (scenic)

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.