If you call
cart.php directly from the browser, it’s not going to have any values to display, because they are passed in by your JS call. I can’t see your screen shot as it’s too small, but it looks as if it is showing empty values, but also the address bar shows you opened it directly, and the summary at the bottom suggests that it was called with “GET”, so of course the
$_POST array will be empty.
I tried your code in a short page and it worked correctly for me. The only thing I changed is that I removed your references to
$row for the values, and put hard-coded values in, because my test code doesn’t connect to a database. So, I suspect that’s the problem.
The first question would then be - if you right-click, “view source” and look at your button code, does it have the correct values that are coming from the
$row result set? And are all the quotes in the correct place? My test code line looks like this:
<button type="button" class="btn btn-primary" type="submit" onclick="addCart('7','5');" style="padding: 5px 83px 5px 83px;">Add to PlayList </button>
and when I add back in your
alert(), my test PHP code just does a
var_dump($_POST) and it shows the values I expect when I click the button.