// 1) always save first (reliable record)
$saved=false;
try {
get_db()->prepare("INSERT INTO contact_messages (name,phone,email,message,ip) VALUES (:n,:p,:e,:m,:ip)")
->execute([':n'=>$old['name'],':p'=>$old['phone'],':e'=>$old['email'],':m'=>$msg,':ip'=>$ip]);
$saved=true;
} catch (Throwable $ex) { $errors['general']='Sorry, something went wrong. Please call us instead.'; }
if ($saved) {
throttle_record('contact:'.($_SERVER['REMOTE_ADDR'] ?? 'x'), false);
// 2) notify admin (best-effort)
$adminEmail = $emails[0] ?? trim((string)get_setting('from_email',''));
if ($adminEmail && filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
send_email($adminEmail, 'New contact enquiry',
"New enquiry from the website:\n\nName: {$old['name']}\nPhone: {$old['phone']}\nEmail: {$old['email']}\n\nMessage:\n{$msg}");
}
// 3) acknowledge the sender (best-effort)
send_email($old['email'], 'We received your message',
"Thank you for contacting " . SITE_NAME . ". We've received your message and our team will call you back within 24–48 hours.\n\nYour message:\n\"{$msg}\"", $old['name']);
flash('contact', "Thank you! We've received your message and will call you back within 24–48 hours.", 'success');
redirect(url('contact'));
}
}
}
$page_title='Contact — '.SITE_NAME;
require TEMPLATES_PATH.'/head.php'; require TEMPLATES_PATH.'/header.php';
?>
Families and tutors send us a message and we'll call you back within 24 to 48 hours, or reach us directly below.We're here to help
Fill this in and we'll call you back usually much sooner than 48 hours.