0
I have a form that has a <span>
that works as a slider that you select a value and with it is carried out the sending of an email. But I also need it sent to the database, and I can’t make that happen.
Form:
<form class="form-carro" method="POST">
<div class="form">
<h4>Valor do consórcio: <span class="slider-value quote-form-element" data-name="Valor" data-slider-id="consorcio-auto">R$ <span></span></span>
</h4>
<div class="slider" data-slider-min="20000" data-slider-max="100000" data-slider-start="23192" data-slider-step="1000" data-slider-id="consorcio-auto"></div>
<h4>Seus dados:</h4>
<input type="hidden" name="Consórcio" value="Automóvel" />
<input type="text" name="Nome" placeholder="Nome..." class="quote-form-element" />
<input type="text" name="Cidade" placeholder="Cidade/UF..." class="quote-form-element quote-form-client-email last" />
<input type="text" name="Telefone" placeholder="Telefone..." class="quote-form-element telefone" />
<input type="text" name="Email" placeholder="E-mail..." class="quote-form-element quote-form-client-email last contact_email" />
<button class="button button-navy-blue send-quote" type="submit" id="enviar">Simular meu consórcio <i class="fa fa-paper-plane-o"></i></button>
<div class="quote-form-thanks">
<div class="quote-form-thanks-content">
Obrigado pelo seu interesse, retornaremos em breve ;).
<span class="quote-form-thanks-close">Fechar</span>
</div>
</div>
</div>
</form>
Send BD php
<?php
$con = mysql_connect("localhost", "******", "########");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("joinmene_leads", $con);
$valor = $_POST[Valor];
$nome = $_POST[Nome];
$cidade = $_POST[Cidade];
$telefone = $_POST[Telefone];
$email = $_POST[Email];
$sql = "INSERT INTO automovel (valor, nome, cidade, telefone, email )
VALUES
('$valor','$nome','$cidade','$telefone','$email')";
if (!mysql_query($sql, $con))
mysql_close($con)
?>
This is the script that performs sending by email:
$.martanianConfigureValueSlider = function() {
$("#quote-popup .quote-form .slider, section.quote-forms .slider").each(function() {
var a = $(this).data("slider-min"),
b = $(this).data("slider-max"),
c = $(this).data("slider-start"),
d = $(this).data("slider-step"),
e = $(this).data("slider-id");
$(this).noUiSlider({
start: c,
step: d,
range: {
min: a,
max: b
}
}), $(this).Link("lower").to($('.slider-value[data-slider-id="' + e + '"] span'), null, wNumb({
thousand: ".",
decimals: "0"
}))
})
}, $(".send-quote").click(function() {
var a = $(this).parent(),
b = a.parent().parent(),
d = (b.data("quote-form-for"), {}),
f = "",
g = "",
h = "",
i = "",
j = !1;
a.find(".quote-form-element").each(function(a) {
f = $(this).attr("name"), "undefined" != typeof f && f !== !1 || (f = $(this).data("name")), $(this).hasClass("checkbox") ? g = "yes" == $(this).data("checked") ? $(this).children(".checkbox-values").children(".checkbox-value-checked").text() : $(this).children(".checkbox-values").children(".checkbox-value-unchecked").text() : (g = $(this).is("input") || $(this).is("select") ? $(this).val() : $(this).text(), $(this).is("input") && "" == g || $(this).is("select") && "-" == g ? (j = !0, $(this).addClass("error")) : $(this).removeClass("error")), $(this).hasClass("quote-form-client-name") && (h = $(this).val()), $(this).hasClass("quote-form-client-email") && (i = $(this).val()), d[a] = {
name: f,
value: g
}, a++
}), 0 == j && $.ajax({
url: "_assets/submit.php",
data: {
send: "quote-form",
values: d,
clientName: h,
clientEmail: i
},
type: "post",
success: function(b) {
a.children(".quote-form-thanks").fadeIn(300)
}
})
})
Submit.php
# put the email title here
$title = 'Contato via website';
# email headers
$headers = "MIME-Version: 1.1\n".
"Content-type: text/html; charset=utf-8\n".
"Content-Transfer-Encoding: 8bit\n".
"From: ". $_POST['clientName'] ." <". $_POST['clientEmail'] .">\n".
"Reply-to: ". $_POST['clientName'] ." <". $_POST['clientEmail'] .">\n".
"Date: ". date( "r" ). "\n";
# appointment values
$values = $_POST['values'];
# create rows with values from appointment form
$rows = '';
for( $i = 0; $i < count( $values ); $i++ ) {
$rows .= '<tr>
<td style="width: 200px; font-weight: bold; border: 1px solid #eee; padding: 10px;">'. $values[$i]['name'] .'</td>
<td style="border: 1px solid #eee; padding: 10px;">'. $values[$i]['value'] .'</td>
</tr>';
}
# email content
$content = '<table style="width: 600px; font-size: 11px; border-collapse: collapse;">'. $rows .'</table>';
# sending an email
$result = mail(
OWNER_EMAIL,
"=?UTF-8?B?". base64_encode( $title ) ."?=",
$content,
$headers
);
put the _Assets/Submit.php code please
– Jao Assy
@Jaoassy asked the question
– Pedro Henrique Kuzminskas