include 'db.php'; $db = new db(); extract($_POST); $sql = "SELECT count(*) total from registros where cedula = '{$cedula}' and id_promo = {$id_promo}"; $total = $db->SelectUnico($sql); //$response = array(); if ($total == 0) { $edad = age($anio . '-' . $mes . '-' . $dia); $pais_ip = get_country(get_IP_address()); $sql = "INSERT INTO `registros` (`id_registro`, `id_promo`, `nombre`, `apellido`, `email`, `pais`, `ciudad`, `cedula`, `celular`,`sexo`, `edad`, `dia_nacimiento`, `mes_nacimiento`, `anio_nacimiento`, `ip`, `pais_ip`, `fecha`) VALUES (null, {$id_promo}, '{$nombre}', '{$apellido}', '{$email}', '{$pais}', '{$ciudad}', '{$cedula}', '{$celular}','{$sexo}', '" . $edad . "', '{$dia}', '{$mes}', '{$anio}', '" . get_IP_address() . "', '" . $pais_ip . "', NOW()); "; $response['status'] = $db->Insert($sql); $sql = "SELECT mailing,texto_mailing from promos where id_promo = {$id_promo}"; $a_data = $db->Select($sql); $HTML = $a_data[0]['texto_mailing'] . '<br/><br/><img src="http://bonovirtualcolineal.com/admin/actions/uploads/' . $a_data[0]['mailing'] . '" />'; sendHTMLemail($HTML, $email, 'COLINEAL - Bono Virtual'); } else { $response['status'] = 0; } header("Content-Type: application/json", true); echo json_encode($response); function get_IP_address() { foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $IPaddress) { $IPaddress = trim($IPaddress); // Just to be safe if (filter_var($IPaddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) { return $IPaddress; }
$_SESSION['step2'] = $_POST; if ($_POST['services']) { $_SESSION['step2']['servs'] = genList($_SESSION['step2']['services']); } else { $_SESSION['step2']['servs'] = 'No Food or Beverages Selected'; } header("Location: index.php?pg=step3"); break; case 'step3': $_SESSION['step3'] = $_POST; if ($_POST['firstNm'] == '' || $_POST['lastNm'] == '' || $_POST['email'] == '' || $_POST['phone'] == '') { $_SESSION['note'] = 'Please fill out the required fields to continue!'; header("Location: index.php?pg=step3"); } else { $_SESSION['note'] = ''; if ($_SESSION['step3']['email'] && isValidEmail($_SESSION['step3']['email'])) { $from = $_SESSION['step3']['email']; } else { $from = '*****@*****.**'; } include 'tmpls/emailTmp.php'; //$to = '*****@*****.**'; $to = '*****@*****.**'; if (sendHTMLemail($msg, $from, $to, $subj)) { unset($_SESSION); header("Location: index.php?pg=confirmation"); } } break; } }