I'm getting trouble with my php code. I have a table named: prof_ales with 3 columns: cnp, evaluat and evaluator.
And a button "Send Email". When the client press the button I want to send an email to 2 specific email adresses which are already saved into my table "prof_ales" in the column "evaluator".
Here is my code, and for now it's working, but the message is send only at the last email adress.
<input class="buttom" name="submit" id="submit" tabindex="5" value="Send Email" type="submit">
<?php
if(isset($_POST['submit'])) {
$interogare = ("SELECT * FROM prof_ales WHERE cnp='".$_SESSION['sess_user']."'");
$rezultat = mysql_query($interogare);
while ($rand = mysql_fetch_assoc($rezultat)) {
$ev= $rand['evaluat'];
$to = $rand['evaluator'];
}
$message = "test email ";
$subject = "Received from $ev";
$body = <<<EMAIL
Etc etc
$message
Bla Bla
EMAIL;
$header = "From: quabits.ro";
}
if($_POST){
mail($to, $subject, $body, $header);
echo "Sent";
}
?>
As I said I want to send to both(or more) email adresses any time when button is pressed. Tks.