Hi all,
I used the Flash-db Guestbook Version 2.0 for my website, but now I got into this problem which I havent been able to solve yet.
I could use a little assistance on that.
What works: after a person posts a comment to a photo he/she will receive an e-mail and also an e-mail will be send to the administrator.
What I'd like to achieve is: after a person posts a comment to a photo, everyone who previously posted a comment on the same photo will receive an e-mail (BCC)
What I need is: a way to extract all e-mailaccounts from the 'email' field in the database table, put them in an array (?) and use them one by one to send an e-mail to (BCC privacy reasons) ; after case 'write'.
Hopefully you guys can help me out. All the variables are making me dizzy

<?
/*
-----
Application: Flash-dB GuestBook Version 2.0
Details: mySQL and PHP powered GuestBook
Author: Mohsin Sumar
Website: http://www.flash-db.com
Support: http://www.flash-db.com/Board
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 = ""; // Database User
$DBpass = ""; // Database Pass
$DBName = "fotogallerijen"; // Database Name
$table = "2007_02_01"; // Database Table
$numComments = 10; // 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 = $_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 ' . $_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 "Er zijn nog geen berichten achtergelaten...";
} 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');
$secret = "Verborgen";
print '<b><font color="#FF0000">Name: </b><font color="#666666">' . $name . '<br><b><font color="#FF0000">Comments: </b><font color="#000000">' . $comments . '<br>
<font color="#999999"><i>Date: ' . $time . '</i></font><br><br>';
$i++;
}
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;
case 'write' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_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
$MyName = "blabla";
$MyEmail = "blabla";
$Subject = "Reactie in fotogallerij";
$EmailBody = "$name heeft de volgende reactie geplaatst bij fotogallerij $table :\n$comments\n\nEmailadres afzender: $email\n\n";
$EmailFooter = "blabla";
$SenderEmailBody = "Beste $name,\nBedankt voor het plaatsen van uw reactie op ...";
$SenderEmailFooter = "Tot ziens op ...";
$Message = $EmailBody.$EmailFooter;
$MyMessage = $SenderEmailBody.$SenderEmailFooter;
mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
mail($name." <".$email.">",$Subject, $MyMessage, "From: ".$MyName." <".$MyEmail.">");
// Email Script End
print "&gb_status=Bedankt voor uw bericht!.&done=yes&";
return;
}
print "&gb_status=Error!&";
break;
}
?>