Hello everyone,
I have a table that i use to set up schedules after the record is save i want to send and email to everyone who has been schedule letting them now that they have been schedule i have a template for the email and the code for this but when i hit save the page stays loading and nothing happens, it just stays loading. i hope you can help me, this is the code i use, is there something wrong with it?
global $conn;
$coro = explode(",",$values['chorus']);
$musicos = explode(",",$values['musicians']);
array_push($coro,$values['lead']);
$people = array_merge($coro,$musicos);
$count = count($people) -1;
$arr = explode("-",$values['date']);
$service_date = $arr[1]."/".$arr[2]."/".$arr[0];
$link = '<a href="http://www.worship.mycasadevida.com/services_list.php" style="color:#099;font-size:24px;font-weight:bold">VIEW SCHEDULE</a>';
$subject = "CASA DE VIDA WORSHIP SERVICE ".$service_date;
$from = "From: Casa De Vida Worship<worship@mycasadevida.com>\n";
// load email template
$email_message = file_get_contents("email_template.txt");
$i = 0;
while ($i <= $count){
$sql = "SELECT name,email FROM users WHERE name = '".$people[$i]."'";
$res = db_query($sql,$conn);
$row = db_fetch_array($res);
// replace variables
$email_message = str_replace("##service_date##",$service_date,$email_message);
$email_message = str_replace("##name##",$row['name'],$email_message);
$email_message = str_replace("##practice##","Thursday at 7:30 pm.",$email_message);
$email_message = str_replace("##link##",$link,$email_message);
// send HTML email
runner_mail(array('to' => $row['email'], 'subject' => $subject, 'htmlbody' => $email_message, 'charset' => 'UTF-8'));
}