感謝大家花了一些時間和檢查我的代碼,很不幸,我無法解決它,直到我檢查更多的代碼並重新做了所有事情,因此我能夠發現通過PHP的形式解決方案:從具有多個值的列表中提取數據
我的HTML表單(一些描述是在西班牙,遺憾的是):
<div class="mdl-textfield mdl-js-textfield">
<select class="mdl-textfield__input" name="contactMarca" id="contactMarca">
<option value="Selecciona">Selecciona</option>
<option value="Acura">Acura</option>
<option value="AlfaRomeo">Alfa Romeo</option>
<option value="AstonMartin">Aston Martin</option>
<option value="Audi">Audi</option>
</select>
<label class="mdl-textfield__label" for="contactMarca"> Marca</label><br><br>
</div>
<div class="mdl-textfield mdl-js-textfield">
<select class="mdl-textfield__input" name="contactVersion" id="contactVersion">
<option value="Selecciona">Selecciona</option>
<option value="Acura" data-value="ACURA ILX A-SPEC 4P L4 2.0L ABS BA QC AC GPS R18 AUT., 05 OCUP.">ACURA ILX A-SPEC 4P L4 2.0L ABS BA QC AC GPS R18 AUT., 05 OCUP.</option>
<option value="Acura" data-value="ACURA RL AUT., 05 OCUP.">ACURA RL AUT., 05 OCUP.</option>
<option value="Acura" data-value="ACURA RLX 4P V6 3.5L SPORTSHIFT AUT., 05 OCUP.">ACURA RLX 4P V6 3.5L SPORTSHIFT AUT., 05 OCUP.</option>
<option value="Acura" data-value="ACURA TL AUT., 05 OCUP.">ACURA TL AUT., 05 OCUP.</option>
<option value="Acura" data-value="ACURA TL V6 3.7L SPORTSHIFT R-18 AUT., 05 OCUP.">ACURA TL V6 3.7L SPORTSHIFT R-18 AUT., 05 OCUP.</option>
<button type="submit" id="submit"><span>Enviar </span> <i class="fa fa-long-arrow-right"></i></button>
基本上一切鑊精細,電子郵件發送的信息,但它不」 t發送來自「數據值」的數據
這是m ŸPHP:
<?php
$site_owners_email = '[email protected]'; // Replace this with your own email address
$site_owners_name = 'Page'; // replace with your name
$name = filter_var($_POST['contactName'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['contactEmail'], FILTER_SANITIZE_EMAIL);
$subject = filter_var($_POST['contactSubject'], FILTER_SANITIZE_STRING);
$codigo = filter_var($_POST['contactCopo'], FILTER_SANITIZE_STRING);
$phone = filter_var($_POST['contactPhone'], FILTER_SANITIZE_STRING);
$model = filter_var($_POST['contactModel'], FILTER_SANITIZE_STRING);
$marca = filter_var($_POST['contactMarca'], FILTER_SANITIZE_STRING);
$version = filter_var($_POST['contactVersion'], FILTER_SANITIZE_STRING);
$confirm = filter_var($_POST['contactConfirm'], FILTER_SANITIZE_STRING);
$uso = filter_var($_POST['contactUso'], FILTER_SANITIZE_STRING);
$error = "";
if (strlen($name) < 2) {
$error['name'] = "Please enter your name.";
}
if (!preg_match('/^[a-z0-9&\'\.\-_\+][email protected][a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address";
}
if (strlen($subject) < 2) {
$error['subject'] = "Please enter a subject.";
}
if (strlen($codigo) < 2) {
$error['codigo'] = "Please enter your Code.";
}
if (strlen($phone) < 2) {
$error['phone'] = "Please enter your phone.";
}
if (strlen($confirm) < 6) {
$error['version'] = "Por favor introduce tu Versión.";
}
if (!$error) {
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->AddAddress($site_owners_email, $site_owners_name);
$mail->IsHTML(true);
$mail->From = $email;
$mail->FromName = $name;
$mail->Subject = $subject;
$mail->Body = '<b>Nombre del Asegurado:</b> '. $name .'<br/><b>E-mail:</b> '. $email . '<br/><b>Codigo Postal:</b> '. $codigo . '<br/><b>Telefono:</b> '. $phone . '<br/><b>Modelo:</b> '. $model . '<br/><b>Marca:</b> '. $marca . '<br/><b>Version:</b> '. $confirm . '<br/><b>Tipo de Uso:</b><br/>' . $uso;
$mail->Send();
echo $theResults = <<<EOD
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--=============== basic ===============-->
<meta charset="UTF-8">
<title>Grupo Integral de Seguros | Cotizacion Autos</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="robots" content="index, follow"/>
<meta name="keywords" content="Seguros"/>
<meta name="description" content="Cotizacion Autos, A donde vayas estamos contigo."/>
<meta property="og:title" content="Grupo Integral de Seguros | Cotizacion Autos"/>
<meta property="og:image" content="http://giseguros.com.mx/images/LogoGIlarge-01.png"/>
<meta property="og:url" content="http://giseguros.com.mx/"/>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@" />
<meta name="twitter:creator" content="@" />
<!--=============== css ===============-->
<link type="text/css" rel="stylesheet" href="css/reset.css">
<link type="text/css" rel="stylesheet" href="css/plugins.css">
<link type="text/css" rel="stylesheet" href="css/style.css">
<!--=============== favicons ===============-->
<!-- Standard Favicon-->
<link rel="shortcut icon" href="http://giseguros.com.mx/favicon-196x196.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="http://giseguros.com.mx/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="http://giseguros.com.mx/apple-touch-icon-152x152.png" />
<link rel="icon" type="image/png" href="http://giseguros.com.mx/favicon-196x196.png" sizes="196x196" />
</head>
<body>
HTML to make prettier the result that email has been sent.
</body>
</html>
EOD;
echo "$theResults";
} # end if no error
else {
$response = (isset($error['name'])) ? "<div class='alert alert-danger' role='alert'>" . $error['name'] . "</div> \n" : null;
$response .= (isset($error['email'])) ? "<div class='alert alert-danger' role='alert'>" . $error['email'] . "</div> \n" : null;
$response .= (isset($error['subject'])) ? "<div class='alert alert-danger' role='alert'>" . $error['subject'] . "</div> \n" : null;
$response .= (isset($error['message'])) ? "<div class='alert alert-danger' role='alert'>" . $error['message'] . "</div>" : null;
echo $response;
} # end if there was an error sending
?>
所以我很抱歉,如果是大量的數據,但我想知道我怎麼可以只提取「數據價值」,因爲它只是提取價值,它給我的品牌,從汽車和我需要我的形式在我的PHP描述沒有擰在這個PHP,現在除了數據價值問題,現在完美的作品?
當您執行'$ e_content ='時,您會不斷覆蓋您的電子郵件內容。你需要像'$ e_content。=' – j08691
這樣的文本連接起來。謝謝我已經改變了,這在發送郵件時很有幫助,它給了我提到的所有信息'$ e_body =「Name $ name」。 PHP_EOL。 PHP_EOL; $ e_reply =「電子郵件:$ email \ r \ nTelefono:$ tel」; $ e_content =「消息:\ r \ n $ comment \ r \ n型號:$ model \ r \ n品牌:$ brand \ r \ n版本:$ version \ r \ nCP:$ zip \ r \ nType:$ type」。 PHP_EOL。 PHP_EOL;'只是問題依然存在,它不能給我表單中選擇列表的值,我還能做什麼? – Jivanz