I have a contact form in php , where when we submit we send an email with the data entered.
What I wanted was to insert this data into a table in the HeidiSQL program.
Form Code:
<div class="pagina" id="contactos">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<font align= center face= "Comic Sans MS" size=+1 Color= #003d99>
<?php echo "<p>Contacte-nos</p>"; ?>
</head>
<Fieldset>
<div align="left">
<form>
<legend align="left"> Submeter Comentàrios </legend>
<br />
<form id="submit_form">
Nome: <input type="text" name="name" placeholder="João Santos"required="" id="name" class="form-control" type="text" size =20 />
<br />
Email: <input type="email" name="email" value="" placeholder="[email protected]" size=20 required id="email" class="form-control" />
<br />
<br />
<input TYPE="checkbox" NAME="Remember Me" VALUE="op1" NOT_CHECKED> Remind me
<input Type="Reset" Value="Limpar" />
</form>
</Fieldset>
<div align="left">
<br>
<legend align="left"> Comentários </legend>
<Textarea id="comentarios" name="comentarios" value="" cols=35 rows=5 ></Textarea>
<br>
<br>
<fieldset>
<legend align="left"> Botões de comando </legend>
<input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />
<span id="error_message" class="text-danger"></span>
<span id="success_message" class="text-success"></span>
</fieldset>
<?php echo htmlentities($user_message)?></textarea>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$('#submit').click(function(){
var name = $('#name').val();
var email = $('#email').val();
var comentarios = $('#comentarios').val();
if(name == '' || email == '' || comentarios == '')
{
$('#error_message').html("Necessita de preencher todos os campos");
}
else
{
$.ajax({
url:"Succesmsg.php",
method:"POST",
data:{name:name, email:email, comentarios:comentarios},
success:function(data){
$("form").trigger("reset");
$('#success_message').fadeIn().html(data);
setTimeout(function(){
$('#success_message').fadeOut("Slow");
}, 9999);
}
});
}
});
});
</script>
</div>