There are three pages that I have been working with. I'm trying to alter my guestbook code to carry out this procedure:
*******FIRST PAGE: the form*******
<html>
<head>
<title>comments</title>
<style type="text/css">
<!--
table {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #ffff99;
background-color: #9999ff;
noborder;
}
-->
</style>
</head>
<body bgcolor="#9999FF"><center>
<font color="#FFFF99" face="Verdana"><b>Welcome to the Camp Bethel Guest Book!!! 🙂</b>
<br>
To make an entry, please fill the form out below:</font><br><br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="store_comment.php">
<table width="500" border="0" align="left" cellpadding="4" cellspacing="0">
<tr>
<td width="151"><div align="right">Your Name: </div></td>
<td width="359"> <div align="left">
<input name="name" type="text" size="36">
</div></td>
</tr>
<tr>
<td><div align="right">Your Email Address: </div></td>
<td> <div align="left">
<input name="email" type="text" size="36">
</div></td>
</tr>
<tr>
<td><div align="right">City:</div></td>
<td> <div align="left">
<input name="city" type="text" size="36">
</div></td>
</tr>
<tr>
<td><div align="right">Message: </div></td>
<td> <div align="left">
<textarea name="message" cols="36" rows="6"></textarea>
</div></td>
</tr>
<tr>
<td> <div align="right"> </div></td>
<td align="left"> <div align="left">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td><br> <br>
<?php
// Make DB Connection
$db = mysql_connect("localhost", "katie@localhost", "********");
mysql_select_db("expressions",$db);
$result = mysql_query("SELECT FROM guestbook ORDER BY id DESC");
// Build Table
echo "<table width=\"70%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\">\n";
echo "<tr><td><strong>Name</strong></td><td><strong>Email</strong></td><td><strong>City</strong></td><td width=\"30%\"><strong>Message</strong></td><td><strong>Date</strong></td></tr>\n";
// Populate Table from Guestbook Data
while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td><a href='mailto:%s'>reply</a></td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5]);
}
echo "<td align=\"right\" bgcolor=\"#CCCCCC\" colspan=\"5\"><a href=\"comments.php\">Sign the Guestbook</a></td></table>\n";
// Close Connection
mysql_close();
?>
</td>
</tr>
</table>
</center>
</body>
</html>
*******End FORM*******
*******LAST PAGE: Storing it.*******
<body bgcolor="#9999FF"><center>
<? // code for store_message.php
$dbname = "expressions";
// Connect to Database and select the database to use
$dbi = mysql_connect("localhost", "katie@localhost", "*********") or
die("I cannot connect to the database. Error :" . mysql_error());
mysql_select_db($dbname,$dbi);
// Get the values posted from the Form in comments.php
$name = $_POST["name"];
$email = $_POST["email"];
$city = $_POST["city"];
$message = $_POST["message"];
$date = date('Y-m-d', mktime());
// Insert the Details into the Database
$sql = "INSERT INTO guestbook(name,email,city,message,date) VALUES('$name','$email','$city','$message','$date')";
$result = mysql_query($sql,$dbi);
If ($result)
{
echo "Thank You!!!<br>";
echo "<a href=\"guestbook.php\">Click here to go back to the Guestbook</a>" ;
} else
echo " Your details were not added due to some database problem";
?>
</center>