How to erase messages from PHP scripted Guestbook

Good day to all
I have just finished installing a guestbook from flash-db.com and its working fine

only problem is, i need to learn how to erase entries and im still not sure what to do

  1. i realise i have to make a new Flash movie with delete capabilities. this much i think i can handle.
  2. the tricky end is writing the PHP. i found the PHP script below , and am thinking of using it. I am a little nervous though, as it took me ages to get the original script working…i have pasted it below so if anyone wants to they can check it out. im not even sure if i should use this script to completely replace the original …

any tips or trickcs much much appreciated thankyou very much
-dj

Some of you might be interested in this. I modified the Guestbook v2 script so that you can use an administration tool to edit or delete the entries. Here’s the code for the Guestbook.php file:

<?
/*

Application: Flash-dB GuestBook Version 2.0
Details: mySQL and PHP powered GuestBook
Author: Mohsin Sumar
Website: [u][color=#222222]http://www.flash-db.com[/color][/u]
Support: [u][color=#222222]http://www.flash-db.com/Board[/color][/u]
Notes: Coments are marked by using comment entries symbols. Eg: // Comment

*/

// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = “localhost”; // Database Server
$DBuser = “yourDBuser”; // Database User
$DBpass = “yourDBpassword”; // Database Pass
$DBName = “yourDBname”; // Database Name
$table = “guestbook”; // Database Table
$numComments = [QUOTE]%4$s
GET[‘numComments’]; // Number of Comments per page
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
$action =

%4$s
GET[‘action’];

switch($action) {
case ‘read’ :
// Fetch all comments from database table
$sql = ‘SELECT * FROM ' . $table . '’;
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ’ ORDER BY time DESC LIMIT ’ .

%4$s
GET[‘NumLow’] . ', ’ . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print ‘&totalEntries=’ . $numallComments . ‘&’;
print “<br>&entries=”;

if($numallComments == 0) {
print “No entries in the guestbook, as yet…”;
} else {
while ($array = mysql_fetch_array($fewComments)) {
$name = mysql_result($fewComments, $i, ‘name’);
$email = mysql_result($fewComments, $i, ‘email’);
$comments = mysql_result($fewComments, $i, ‘comments’);
$time = mysql_result($fewComments, $i, ‘time’);

print ‘<b>Name: </b>’ . $name . ‘<br><b>Email: </b>’ . $email . ‘<br><b>Comments: </b>’ . $comments . '<br><i>Date: ’ . $time . ‘</i><br><br>’;
$i++;
}
}
// Print this only when there aren’t any more entries…
if(

%4$s
GET[‘NumLow’] > $numallComments) {
print ‘No More Entries!&’;
}
break;

case ‘write’ :
// Recieve Variables From Flash
$name = ereg_replace(“&”, “%26”,

%4$s
POST[‘yourname’]);
$email = ereg_replace(“&”, “%26”,
%4$s
POST[‘youremail’]);
$comments = ereg_replace(“&”, “%26”,
%4$s
POST[‘yourcomments’]);
$submit =
%4$s
POST[‘submit’];

// Current system date in yyyy-mm-dd format
$submitted_on = date (“Y-m-d H:i:s”,time());

// Check if its submitted from Flash
if($submit == ‘Yes’){
// Insert the data into the mysql table
$sql = ‘INSERT INTO ’ . $table .
’ (ID,
name,
email,
comments,
time
)
VALUES
('',’
. ‘'’ . $name . ‘',’
. ‘'’ . $email . ‘',’
. ‘'’ . $comments . ‘',’
. ‘'’ . $submitted_on . ‘'
)’;
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin

/* <– Remove this line
$MyName = “Mohsin Sumar”;
$MyEmail = “[email protected]”;
$Subject = “$name has just signed your guestbook.”;
$EmailBody = "Hello Mohsin,
$name has just signed your guestbook available at [u][color=#222222]http://www.mohsinsumar.com[/color][/u]. THe following were the details submitted into your guestbookn
Name: $name
Email: $email
Commentn$comments
";

$EmailFooter = "~~~~~~~~~~~~~~~
The guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from [url=“http://www.mohsinsumar.com/n~~~~~~~~~~~~~~~/nThanking”][u][color=#222222]http://www.mohsinsumar.com

Thanking[/color][/u] you,
Mohsin Sumar";

$Message = $EmailBody.$EmailFooter;

mail($MyName." &lt;".$MyEmail."&gt;",$Subject, $Message, "From: ".$name." &lt;".$email."&gt;");
--&gt; Remove this line */

// Email Script End

print "&gb_status=Thank you for signing my guestbook.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;

case 'edit' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", 
> %4$s
 POST['yourname']);
$email = ereg_replace("&", "%26", 
> %4$s
 POST['youremail']);
$comments = ereg_replace("&", "%26", 
> %4$s
 POST['yourcomments']);
$submit = 
> %4$s
 POST['submit'];
$entryNum = 
> %4$s
 POST['entryNum'];

// Check if its submitted from Flash
if($submit == 'Yes'){
$sql = "SELECT * FROM $table ORDER BY `ID` DESC LIMIT " . 
> %4$s
 GET['NumLow'] . ", " . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$id = mysql_result($fewComments, 0, 'ID');
// Insert the data into the mysql table
$sql = "UPDATE $table SET name='$name', email='$email', comments='$comments' WHERE ID='$id'";
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

print "&gb_status=The guestbook has been edited.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
case 'delete' :
// Recieve Variables From Flash
$submit = 
> %4$s
 POST['submit'];
$entryNum = 
> %4$s
 POST['entryNum'];

// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());

// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = "SELECT * FROM $table ORDER BY 'ID' DESC LIMIT " . 
> %4$s
 GET['NumLow'] . ",1";
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$id = mysql_result($fewComments, 0, 'ID');
// Insert the data into the mysql table
$sql = "DELETE FROM $table WHERE ID ='$id'";
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
print "&gb_status=Entry deleted.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
}
?&gt;[/QUOTE]