X BOL wishing you a very and Happy New year

Alternative content

Insert data through ajax into MySql database.

Insert data through ajax into MySql database.1. Create form.php and copy below code into file.

<script type="text/javascript">

$(document).ready(function(){
$('#submit').click(function(){
var name= $('#name').val();
var email= $('#email').val();
var sdatatring='name1='+ name +'&email1='+ email;
$.ajax({
type:"POST",
url:"insert.php",
data:sdatatring,
cache: false,
success:function(result){
alert(result);

}});

});

});
</script>
<form method="post" action="" name="frm">
Name:<input type="text" name="name" id="name" value=""><br>
Email:<input type="text" name="email" id="email" value=""><br>
<input type="button" name="submt" id="submit" value="submit" />

</form>

2. Create insert.php and copy below code into file.
<?php
print_r($_POST);
$con=mysql_connect("localhost","root","");
mysql_select_db('dbname');
mysql_query('insert into tablename('colname')values(value)');
?>
Note:You need to include jQuery library in form.php.

More at

https://phpajaxhtml.blogspot.in/2018/03/insert-data-through-ajax-into-mysql.html