this is error :- GET http://myproject.com/insertData?amount=100&item=shoes 500 (Internal Server Error)
this is a javascript code :-
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('paypal_form');
form.addEventListener('submit', function() {
setData(document.getElementById('amount').value, document.getElementById('item').value);
});
function setData(amount, item) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
};
xhttp.open("GET", "/insertData?
amount="+amount+"&item="+item, true);
xhttp.send();
}
});
</script>
this is a insertdata code :-
<?php
session_start();
// Include database connection file
include_once 'dbConnect.phtml';
$amount = $_GET['amount'];
$item = $_GET['item'];
$status = "pending";
$insert = $db->query("INSERT INTO product(product_name,
price, status1)
VALUES('".$item."','".$amount."','".$status."')");
if (!$insert) {
die("Error: " . $db->error);
}
$last_id = $db->insert_id;
$_SESSION['product_id'] = $last_id;
I am using laminas framework for develop app with PayPal. but its not save data to databases come this error. I need to fix this.
'insertData' => [
'type' => Literal::class,
'options' => [
'route' => '/insertData',
'defaults' => [
'controller' =>
ControllerViewController::class,
'action' => 'insertData',
],
],
],
this is a route in module.config.php