I have a form that records the data in phpmyadmin, but when the data is sent, the page a reload to php. I've tried ajax, and I have seen that it can help me, but I did not quite understand how to use it and I do not know if it's possible to send it to the database, I just saw it talking about emails.
<?php
$con = mysql_connect("localhost","*$*$*$","*%*%*%**%");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("joinmene_leads", $con);
$sql="INSERT INTO automovel (valor, nome, cidade, telefone, email )
VALUES
('$_POST[Valor]', '$_POST[Nome]','$_POST[Cidade]','$_POST[Telefone]','$_POST[Email]')";
if (!mysql_query($sql,$con))
echo "";
mysql_close($con)
?>
Form:
<form action="insert.php" method="POST">
<h4>Valor do consórcio: <span class="slider-value quote-form-element" data-name="Valor | Automóvel" 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">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>
</form>
Is it possible to use ajax?