include("common.php"); $ok = true; $error = array(); if($post) { $ok = empty($error) && !empty($_POST); if($ok) { include('phpmailer/class.phpmailer.php'); // Cargamos la plantilla $tpl = file_get_contents(realpath("test_historia_clinica.tpl")); // Reemplazamos los campos que hemos recibido en el POST $_POST['imc'] = round(intval($_POST['peso']) / pow(intval(str_replace('.', '', $_POST['altura'])) / 100, 2), 2); foreach($_POST as $key=>$value) { if($value=='') $value = ''; $tpl = str_replace("[{$key}]", ''.$value.'', $tpl); } $tpl = preg_replace("/\[([\w_]*)\]/", '', $tpl); // Enviamos correo como HTML $nom = isset($_POST['nombre']) ? $_POST['nombre'] : '-'; $tel = isset($_POST['telefono']) ? $_POST['telefono'] : '-'; $eml = isset($_POST['email']) ? $_POST['email'] : '-'; email('Estudio preliminar', $tpl, $nom, $tel, $eml); if(intval($_POST['revista'])==1) { include('wp-content/themes/clobe/include/MCAPI.class.php'); include('wp-content/themes/clobe/include/config.inc.php'); $api = new MCAPI($apikey); $res = $api->listSubscribe($listId, $_POST["email"],NULL,'html',false); } header('location: form-historia-clinica-respuesta.php'); } } ?>