P. S this is the code i have got with the delete option --- just displaying the message in a box i can edit is whats hard🙂
<HTML>
<HEAD>
<TITLE></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</HEAD>
<BODY>
Castle Fm Guestbook<br><br>
<center><FORM METHOD="POST" ACTION="?page=gbook">
Your Name: <INPUT NAME="Name" size="20" value="Enter Name"><BR>
Your Email : <INPUT NAME="Email" size="20" value="Enter Email"><BR>
Your Comment:<BR>
<TEXTAREA NAME="Comment" COLS=40 ROWS=8>Enter Comment</TEXTAREA><BR>
<INPUT TYPE=SUBMIT VALUE="Sign Guestbook">
</FORM>
<HR><P></center>
<?php
function killnasty($Id)
{
$link = mysql_connect("localhost","castlefm","*********") or die(mysql_error());
mysql_select_db("castlefm_net",$link) or die(mysql_error());
$query="DELETE from GuestTable WHERE Id = $Id";
mysql_query($query) or die(mysql_error());
}
if( isset($delete))
{
killnasty($delete);
echo "The nasty entry was removed.";
return $query;
mysql_close();
}
?>
<?php
mysql_connect ("localhost","castlefm","*********") or die ("Cannot connect to the SQL server."); // Connecting to the database server
mysql_select_db ("castlefm_net") or die ("Cannot select database."); // Selecting the database
if ($Name AND $Email AND $Comment) { // If someone signs in the guestbook, insert the information into the database
$Query = "INSERT INTO GuestTable (Name, Email, Date, Comment) ";
$Query .= "VALUES ('$Name', '$Email', NULL, '$Comment')";
mysql_query ($Query) or die ("Insert Failed!");
}
$Query = "SELECT * FROM GuestTable ORDER BY Id DESC";
$GuestArray = mysql_query ($Query) or die ("Select Failed!");
$Total = mysql_num_rows ($GuestArray);
echo ("Total $Total messages posted. ");
echo ("<A HREF=?page=gbook&showall=1>Show all</A>. ");
echo ("<A HREF=?page=gbook&showall=0>Show last 5</A>."); // If you want to change the number of last messages to be displayed, change the line 38 accordingly
if ($showall == 0) {
$Query .= " LIMIT 5";
$GuestArray = mysql_query ($Query) or die ("Select Failed!");
}
while ($Guest = mysql_fetch_array ($GuestArray)) { // Dump out information in each message
echo ("<P><TABLE BORDER=0 WIDTH=500>");
echo ("<TR><TD VALIGN=TOP WIDTH=200>");
echo ("Name: " . $Guest['Name'] . "<BR>");
echo ("Email: " . $Guest['Email'] ."<BR>");
echo ("<a href='{$_SERVER['PHP_SELF']}?delete=" . $Guest['Id'] ."'>DELETE ENTRY</a><Br>
");
$DateStamp = $Guest['Date'];
$Year = substr ($DateStamp, 0, 4);
$Month = substr ($DateStamp, 4, 2);
$Day = substr ($DateStamp, 6, 2);
echo ("Date: $Day/$Month/$Year</TD>"); // You may want to chage the date format as you like
echo ("<TD VALIGN=TOP>" . nl2br ($Guest['Comment']) . "</TD>");
echo ("</TR></TABLE>");
}
?>
</BODY>
</HTML>