Heres the problem. Im creating a guestbook using php. I tried many scripts to try and refresh the page after an entry. None works. Now im stuck i need some help.
This is the url to my guestbook:
http://www.bangkokcityonline.com/guestbook.php
here is the script for the guestbook:
<? include('testimonial.php') ?>
<?php
if (isset ($_POST['submit']))
{
if ($dbh = mysql_connect ('localhost', '*********', '******'))
{
if (!@mysql_select_db ('koulaid_entry'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
}
$title = $_POST['title'];
$text = $_POST['entry'];
$id = $_POST['id'];
$query = "INSERT INTO gbook (name_id, title, text) VALUES ('$id','$title', '$text')";
if (@mysql_query ($query))
{
print '<p>Thank you for the comments.</p>';
}
else
{
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
print '<b>Name: </b>' . ($_POST['id']) . '<br />';
print '<b>Subject: </b>' . ($_POST['title']) . '<br />';
print '<b>Comments: </b>' . ($_POST['entry']) . '<br />';
mysql_close();
}
/*
END OF PHP SCRIPT
*/
?>
<body>
<table class="guestbook">
<tr>
<td style="padding-top: 17px;">
<form action="guestbook.php" method="POST">
<table cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td colspan="2"><h3 align="center">Leave a comment</h3></td>
</tr>
<tr>
<td>Name:
</td>
<td><input type="text" name="id" maxlength="255" value="<?=$_POST['id']?>">
</td>
</tr>
<tr>
<td>Subject:
</td>
<td><input type="text" name="title" maxlength="255" value="<?=$_POST['title']?>">
</td>
</tr>
<tr>
<td>Comments:
</td>
<td><textarea name="entry" value="<?=$_POST['entry']?>" maxlength="255"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value=" Sign " />
</td>
</table>
</form>
</td>
</tr>
</table>
</body>
here is the include script testimonial.php:
<head>
<style type="text/css">
body
{
background-color: FFEECC;
}
hr
{
width: 300px;
text-align: left;
}
table.main
{
vertical-align: middle;
}
table.guestbook
{
border-style: dotted;
height: 180px;
width: 300px;
}
font.font
{
font-size: 18;
color: 851325;
}
</style>
</head><body>
<h1 align="center">Bangkok City Thai Cuisine's Guestbook</h1><br>
<h2>Feedbacks/Testimonials</h2><br><br>
<!----------- BEGINNING OF PHP SCRIPT ----------------------->
<?
if ($dbh = mysql_connect ('localhost', 'koulaid_kou', 'jackpot'))
{
if (!@mysql_select_db ('koulaid_entry'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
}
$query = 'SELECT * FROM gbook';
if ($result = mysql_query ($query))
{
while ($row = mysql_fetch_array ($result))
{
$field1= $row["name_id"];
$field2= $row["title"];
$field3= $row["text"];
echo "<font class='font'>Name:</font> <b>$field1</b><br>";
echo "<font class='font'>Subject:</font> <b>$field2</b><br>";
echo "<font class='font'>Comments:</font> <b>$field3</b><br>";
echo "<table><tr><td><hr width='300px'></td></tr></table>";
}
}
else
{
die ('could not get it cuz: <b>' . mysql_error() . "</b> . the query was $query");
}
mysql_close();
?>
</body></html>