So I have problem where I am using AJAX + PHP to insert product id to $SESSION['korpica'] = array();
Everything is working for id where i have only numbers(222,223,440,900,911) but when it comes to (A320M BAZOOKA, A320M GAMING PRO, A320M PRO-VH PLUS) it is not working.
I searched but nothing helped me. Here is my code .
Declaring array in index.php
session_start();
$korpa = array();
$_SESSION['korpica'] = $korpa;
button
<button type="button" class="addToCart btn-button" title="Dodaj u korpu" onclick="dodaj('<?php echo $sifra; ?>');"> <i class="fa fa-shopping-basket"></i>
<span>Add to Cart</span>
</button>
dodaj.js
function dodaj(sifra) {
$.ajax({
url: 'dodajUKorpu.php',
type: "GET",
data: {'korpas':sifra}
});
}
dodajUKorpu.php
<?php session_start(); ?>
<?php
if(isset($_GET['korpas']) && $_GET['korpas']!=0){
array_push($_SESSION['korpica'], $_GET['korpas']);
}
?>
Working for id -> 222, 223, 444, 900, 121, 911
Not working for id -> A320M BAZOOKA, A320M GAMING PRO, A320M PRO-VH PLUS, A68HM-P33 V1, AD5150JAHMBOX