I made this code inside script to save datasource event in database but nothing happens, no values are saved in the database:
$.ajax({
url:"insert.php",
type:"POST",
data:{id:event.id, name:event.name, startDate:event.startDate, endDate:event.endDate},
success:function(){
alert("Added Successfully");
}
})
file insert.php:
<?php
$connect = new PDO('mysql:host=localhost;dbname=recuperation', 'root', '');
$query = "INSERT INTO events (id, name, startDate, endDate) VALUES (:id, :name, :startDate, :endDate)";
$statement = $connect->prepare($query);
$statement->execute( array(':id' => $_POST['event.id'], ':name' => $_POST['event.name'], ':startDate' => $_POST['event.startDate'],':endDate' => $_POST['event.endDate']));
?>