i'm sorry but i'm still having some problems. the thing is the email addresses are taken from database using 3 different SQL queries...
this was what i did
CODE
$result2=mysql_query("Select c.CON_TITLE,c.USER_NAME,m.F_NAME,m.L_NAME from Contestants c, Membership m WHERE
c.USER_NAME = m.USER_NAME and
c.CON_TITLE = '$CON_TITLE'");
echo "Contest Title: " .$CON_TITLE;
//start of form
//echo "<form name='form1' method='POST' action=''>";
echo "<table border = '1'>";
echo "<tr><th>First name</th>";
echo "<th>Last name</th>";
echo "<th>Username</th>";
echo "<th>Yes</th>";
echo "<th>No</th>";
while($row=mysql_fetch_array($result2)) {
echo "<tr><td>";
echo "<form name='form1' method='POST' action=''>";
echo $row['F_NAME'].'</td><td>';
echo $row['L_NAME'].'</td><td>';
echo $row['USER_NAME'].'</td><td>';
echo "<input type='Submit' name='Yes' value='Yes'></td><td>";
echo "<input type='Submit' name='No' value='No'></td>";
echo "<input type='hidden' name='FormUsername' value='".$row['USER_NAME']."'/>";
echo "</form>";//end of form
}
"</tr>";
echo "</table>";
$username = $_REQUEST['FormUsername'];
mysql_query("UPDATE Contestants SET STATUS = 'winner' WHERE CON_TITLE = '$CON_TITLE' AND USER_NAME = '$username' ");
$result= mysql_query("SELECT DISTINCT Contestants.USER_NAME, Contestants.JOINED_DATE, Contestants.CON_TITLE, Contest2.END_DATE, Contest2.START_DATE, Contest2.CAT_TITLE, Contest2.CON_DESC, Contest2.PRIZE_AMT, Membership.USER_NAME, Membership.EMAIL
FROM Contest2, Contestants, Membership
WHERE Contestants.USER_NAME = '$username'
AND Contestants.USER_NAME = Membership.USER_NAME
AND Contestants.CON_TITLE = '$CON_TITLE'");
if ($rows=mysql_fetch_array($result)){
//information to be emailed
$your_username = $rows['USER_NAME'];
$your_con_title = $rows['CON_TITLE'];
$your_con_desc = $rows['CON_DESC'];
$your_cat_title = $rows['CAT_TITLE'];
$your_joined_date = $rows['JOINED_DATE'];
$your_end_date = $rows['END_DATE'];
$your_start_date = $rows['START_DATE'];
$your_prize_amt = $rows['PRIZE_AMT'];
//will not be shown in email
$email = $rows['EMAIL'].
//getting adver's email
$email2_stat = mysql_query("SELECT Membership.EMAIL, Contest2.USER_NAME, Contest2.CON_TITLE FROM Membership, Contest2
WHERE Contest2.USER_NAME = Membership.USER_NAME
AND Contest2.USER_NAME = '$_COOKIE[ID_my_site]'");
while ($email_rows2 =mysql_fetch_array($email2_stat)){
$username2 = $email_rows2['USER_NAME'].'</td><td>';
$email2 = $email_rows2['EMAIL'].'</td><td>';
}
//getting admin's email
$email3_stat = mysql_query("SELECT EMAIL, USER_NAME, ACCESS_LEVEL FROM Membership
WHERE ACCESS_LEVEL = 'admin'");
while ($email_rows3 =mysql_fetch_array($email3_stat)){
$username3 = $email_rows3['USER_NAME'].'</td><td>';
$email3 = $email_rows3['EMAIL'].'</td><td>';
}
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
//$to="lala@hotmail.com";
$to = $email . ', '
$to. = $email2 . ', '; // note the comma
$to .= $email3 . ', ';
// Your subject
$subject="PPC Forget password!";
//
// From
$header="From: ppc<ppc@gmail.com>";
//
//// Your message
$messages= "Hello $your_username\r\n";
$messages.= "You're the winner of $your_con_title \r\n";
$messages.="Contest Description: $your_con_desc \r\n";
$messages.="Contest Category: $your_cat_title\r\n";
$messages.="Contest Date: $your_joined_date\r\n";
$messages.="End Date: $your_end_date\r\n";
$messages.="Start Date: $your_start_date\r\n";
$messages.="Prize Amount: $your_prize_amt\r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
$email is the winner
$email2 is the advertiser
$email3 is the admin
i cant seem to get the $to to read the emails from my DB. it only works when i type out the email adds. Could u kindly explain why is tat so....thanks your help would be very appreciated..