I am trying to submit a normal html form to a database:
<form method="post" action="#" id="productForm" onsubmit="return submitProduct(this);">
With the above line I call the method "submitProduct". The code for this method is:
function submitProduct(form_ele) {
var values = $(form_ele).serialize();
$.ajax({
url: "forms/ajax/admin/form_modifications.php",
type: "post",
data: values,
success: function (response) {
alert("Success");
},
});
}
So with the above code I should be able to go in "form_modifications.php" script right? I haven't managed to get the "data: values" from the form yet (which it should be fine once I figure out how to go there)
In form_modifications.php I have the following (I wanted just to test it):
chdir(dirname(__FILE__)."/../../..");
require_once("config/config.inc.php");
require_once("init.php");
$sql_test = "INSERT INTO ps_test_product (name) VALUES ('test');";
Db::getInstance()->query($sql_test);
I can't understand why but it doesn't work. The query is not executed and I can't find what I am doing wrong. Can anyone help me with this?