Hi, I have a guestbook function that I'm trying to get to work, it all works, except when trying to submit a post. I use 1 table on my database for all my guestbooks, mainly band guestbooks, so artist is the column to defferenciate between different bands.
Any help would be much appreciated.
function guestbook($sitename) {
if ($btnSubmit) {
if (($name == '') or ($email == '') or ($comment == ''))
{
echo '
<center>
<b>Sorry, not all fields were filled in!</b>
</center>
<hr>';
}else{
$time = date("G\:i j\/n\/Y");
$comment2 = nl2br("$comment");
mysql_query ("INSERT INTO guestbook (artist, time, name, email, message, ip)
VALUES ('$sitename', '$time', '$name', '$email', '$comment2', '$ip')");
echo '
<center>
<b>Thankyou, your comment has now been posted!</b>
</center>
<hr>';
}}
$query = "SELECT id, time, name, email, message, ip FROM guestbook WHERE artist = '$sitename' ORDER BY id desc LIMIT 15";
$result = mysql_query($query);
while(list($id, $time, $name, $email, $comment, $ip) = mysql_fetch_row($result))
echo '
<div class="article">
<div class="article_title">Posted by <a href="mailto:'. $email .'">'. $name .'</a> - '. $time .'</div>
<div class="article_content">
'. $comment .'
</div>
</div>';
echo '
<hr>
<form action="" method ="POST">
<table align="center">
<tr valign="top">
<td>Name:</td>
<td><input type="text" name="name"></td>
</tr>
<tr valign="top">
<td>E-Mail: </td>
<td><input type="text" name="email"></td>
</tr>
<tr valign="top">
<td>Message: </td>
<td><textarea name="comment"></textarea></td>
</tr>
<tr valign="top">
<td> </td>
<td><input type="submit" name="btnSubmit" value="Submit"></td>
</tr>
</table>
</form>';}
Ryan x