i am trying to create a simple guestbook to include in a web site. i cant get the form to add the data to the database nevermind post the entries. there are 3 files guestbook, addguestbook and view guestbook. im using server2go and dont know whether there is something in the config file that i have not changed properly. all the pages are stored in htdocs. heres the coding for the pages.
guestbook
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>Test Sign Guestbook </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form id="form1" name="form1" method="post" action="addguestbook.php">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="name" type="text" id="name" size="40" /></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong><a href="viewguestbook.php">View Guestbook</a> </strong></td>
</tr>
</table>
addguestbook
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="mywebsite"; // Database name
$tbl_name="guestbook"; // Table name
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"); //date time
$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
$result=mysql_query($sql);
//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='viewguestbook.php'>View guestbook</a>";
else {
echo "ERROR";
}
mysql_close();
?>
view guestbook
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>View Guestbook | <a href="guestbook.php">Sign Guestbook</a> </strong></td>
</tr>
</table>
<br>
<?php
$host="localhost";
$username="root";
$password="";
$db_name="mywebsite";
$tbl_name="guestbook";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td>ID</td>
<td>:</td>
<td><? echo $rows['id']; ?></td>
</tr>
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><? echo $rows['name']; ?></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><? echo $rows['email']; ?></td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><? echo $rows['comment']; ?></td>
</tr>
<tr>
<td valign="top">Date/Time </td>
<td valign="top">:</td>
<td><? echo $rows['datetime']; ?></td>
</tr>
</table></td>
</tr>
</table>
<BR>
<?
}
mysql_close(); //close database
?>
and also here is the database part of the config file
[database]
;--- 1 if MySQL Server should be started
UseMySQL=1
;--- 1 if the database files from the dbdir directory will be mirrored to
;--- a directory of the local machine
LocalMirror=0
;--- 1 if the mirrored database should be overwritten at each start of the
;--- the server
OverwriteLocalMirror=0
;--- The path to that the database should be mirrored (e.g.. c:\MyS2GApp\Data\) , if empty the
;--- default temp directory is used
MirrorFolder=C:\Users\Steffi\Desktop\dissertation second site\server\distribute_apache2.0\dbdir
;--- If value is 1 all files of the database server will be deleted after
;--- Server shutdown
DeleteDatabaseFiles=0
;--- The port that should be used for MySQL. If empty the default mysql port is used
MySQLPort=7188
;--- Commandline parameters (i.e. skip-innodb)
MySQLCmd=--skip-innodb
;--- If HideMirrorFolder is set to 1 the folder will created as hidden folder
HideMirrorFolder=0
if anyone could help me out i would be very grateful, as the web site is for my dissertation at uni. iv tried looking at other tutorials and even trying them out but the result is always the same. :(