Ciao ho un problema con questo modulo contatti che ho fatto
La mail arriva in maniera coretta na non capisco perchè la variabile del campo select (prodotto) non viene stampata nella mail
grazie in anticipo
http://www.mylifemarco.it/formsia.htm
ecco i file
<?php
$errorMSG = "";
// NAME
if (empty($_POST["name"])) {
$errorMSG = "Name is required ";
} else {
$name = $_POST["name"];
}
// CUGNOME
if (empty($_POST["cognome"])) {
$errorMSG = "Cognome is required ";
} else {
$cognome = $_POST["cognome"];
}
// EMAIL
if (empty($_POST["email"])) {
$errorMSG .= "Email is required ";
} else {
$email = $_POST["email"];
}
// TELEFONO
if (empty($_POST["telefono"])) {
$errorMSG .= "Telefono is required ";
} else {
$telefono = $_POST["telefono"];
}
// PRODOTTO
if (empty($_POST["prodotto"])) {
$errorMSG .= "Prodotto is required ";
} else {
$prodotto = $_POST["prodotto"];
}
// MESSAGE
if (empty($_POST["message"])) {
$errorMSG .= "Message is required ";
} else {
$message = $_POST["message"];
}
$EmailTo = "m.zarpellon30@gmail.com";
$Subject = "Richiesta informazioni";
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Cognome: ";
$Body .= $cognome;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Telefono: ";
$Body .= $telefono;
$Body .= "\n";
$Body .= "Prodotto: ";
$Body .= $prodotto;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From:".$email);
// redirect to success page
if ($success && $errorMSG == ""){
echo "success";
}else{
if($errorMSG == ""){
echo "Something went wrong :(";
} else {
echo $errorMSG;
}
}
?>
$("#contactSIA").validator().on("submit", function (event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
formError();
submitMSG(false, "I campi sono tutti obbligatori");
} else {
// everything looks good!
event.preventDefault();
submitForm();
}
});
function submitForm(){
// Initiate Variables With Form Content
var name = $("#name").val();
var cognome = $("#cognome").val();
var email = $("#email").val();
var telefono = $("#telefono").val();
var prodotto = $("#prodotto").val();
var message = $("#message").val();
$.ajax({
type: "POST",
url: "php/form-contatti-sia.php",
data: "name=" + name + "&cognome="+ cognome + "&email=" + email + "&telefono=" + telefono + "&prodotto=" + prodotto + "&message=" + message,
success : function(text){
if (text == "success"){
formSuccess();
} else {
formError();
submitMSG(false,text);
}
}
});
}
function formSuccess(){
$("#contactSIA")[0].reset();
submitMSG(true, "Messaggio inviato")
}
function formError(){
$("#contactSIA").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$(this).removeClass();
});
}
function submitMSG(valid, msg){
if(valid){
var msgClasses = "h3 text-center tada animated text-success";
} else {
var msgClasses = "h3 text-center text-danger";
}
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
}
<!DOCTYPE html>
<html>
<head>
<title>Modulo Contatti</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/animate.css">
</head>
<body>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<div class="well" style="margin-top: 10%;">
<h3>Invia una richiesta</h3>
<form role="form" id="contactSIA" data-toggle="validator" class="shake">
<div class="row">
<div class="form-group col-sm-3">
<label for="name" class="h4">Name</label>
<input type="text" class="form-control" id="name" placeholder="Inserisci Nome" required>
</div>
<div class="form-group col-sm-3">
<label for="cognome" class="h4">Cognome</label>
<input type="text" class="form-control" id="cognome" placeholder="Inserisci Cognome" required>
</div>
<div class="form-group col-sm-6">
<label for="email" class="h4">Email</label>
<input type="email" class="form-control" id="email" placeholder="Inserisci Email" required>
</div>
<div class="form-group col-sm-3">
<label for="telefono" class="h4">Telefono</label>
<input type="text" class="form-control" id="telefono" placeholder="Inserisci numero di telefono" required>
</div>
<div class="form-group col-sm-9">
<label for="prodotto" class="h4">Prodotto</label>
<select type="text" class="form-control" id="select" required>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
</div>
</div>
<div class="form-group">
<label for="message" class="h4 ">Messaggio</label>
<textarea id="message" class="form-control" rows="5" placeholder="Di cosa hai bisogno???" required></textarea>
</div>
<button type="submit" id="form-submit" class="btn btn-success btn-lg pull-right ">Invia Richiesta</button>
<div id="msgSubmit" class="h3 text-center hidden"></div>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/validator.min.js"></script>
<script type="text/javascript" src="js/form-scripts.js"></script>
</html>