ajax Why my code is all correct but its still not working?
$(document).ready(function(){
$('.trolley').click(function(){
$(this).find('i').toggleClass('open'); // call the icon class in h3 class and add .open
$('.addbar').toggleClass('open');
});
$('.a1').click(function(){
var qunti = $('#itemnum1').val();
var id = $('#hidden1').val();
$.ajax({
url:"Promotionaddajax.php",
method:"post",
async: false,
data:{
"cart": quanti,
"item": id
},
success:function(data)
{
$('#itemnum1').val('');
}
});
});
});
these are my ajax code I was trying to insert a row of data into database after click on .a1 my code are correct, but it's not working here is my Promotionaddajax.php code.
<?php
session_start()
include "include/conn.php";
$sql = "SELECT * FROM users WHERE User_ID = (SELECT User_ID FROM users WHERE Username = '".$_SESSION['username']."')";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
$userid = $row['User_ID'];
$quanti = $_POST['cart'];
$itemid = $_POST['item'];
$addcart = "INSERT INTO cart (cart_quantity, coupon_id, User_ID) VALUES ('$quanti', '$itemid', '$userid')";
mysqli_query($conn, $addcart);
?>