# PHP Guestbook

**URL:** <https://forum.kirupa.com/t/php-guestbook/292803>\
**Category:** programming\
**Created:** [July 19, 2009, 1:50pm UTC](https://forum.kirupa.com/t/php-guestbook/292803 "2009-07-19T13:50:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joso](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@joso](https://forum.kirupa.com/u/joso)\
**Post date:** [July 19, 2009, 1:50pm UTC](https://forum.kirupa.com/t/php-guestbook/292803/1 "2009-07-19T13:50:42Z")

</div>

hi there,

I’ve just followed a tutorial to create a PHP/MySQL guestbook which seemed to be working but it seems the entries aren’t being added to the database as I check the contents of the table in phpmyadmin, each is empty apart from the id and date/time fields.

you can view the guestbook here : [http://www.predator-uk.net/naa/index.php?p=guestbook](http://www.predator-uk.net/naa/index.php?p=guestbook)

I was assuming it would be the script used to add the data to the database that is the problem but I can’t seem to find whats wrong. This is the script used to process the form data :

```php
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");

$sql="INSERT INTO $tbl_name(name, email, comment, datetime) VALUES 

('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);

if($result){
echo "Successful";
echo "<BR>";
echo "<a href='index.php?p=viewguestbook'>View guestbook</a>"; 
}

else {
echo "ERROR";
}

mysql_close();

```

Hope someone can help,

Cheers,

Jeff :hr:
