Hello everyone, I'm working on an online bookstore and I'm having some problems with the shopping cart section.
On the book page I have the following code, which is supposed to gather information like book title, author and price and send it to the shopping cart:
<form action="cos.php?actiune=adauga" method="post">
<input type="hidden" name="id_carte" value="<?=$id_carte?>">
<input type="hidden" name="titlu" value="<?=$rowCarte['titlu']?>">
<input type="hidden" name="autor" value="<?=$rowCarte['nume_autor']?>">
<input type="hidden" name="pret" value="<?=$rowCarte['pret']?>">
<input type="submit" value="Cumpara acum!">
</form>
Cart.php looks like this:
<?php
session_start();
include("conectare.php");
include("pagetop.php");
include("meniu.php");
$actiune=$_GET['actiune'];
if(isset($_GET['actiune']) && $_GET['actiune']=="adauga")
{
$_SESSION['id_carte'][]=$_POST['id_carte'];
$_SESSION['nr_buc'][]=1;
$_SESSION['pret'][]=$_POST['pret'];
$_SESSION['titlu'][]=$_POST['titlu'];
$_SESSION['nume_autor'][]=$_POST['nume_autor'];
}
if(isset($_GET['actiune']) && $_GET['actiune']=="modifica")
{
for($i=0; $i<count($_SESSION['id_carte']); $i++)
{
$_SESSION['nr_buc'][$i]=$_POST['noulNrBuc'][$i];
}
}
?>
<td align="top">
<h1>Cosul de cumparaturi</h1>
<form action="cos.php?actiune=modifica" method="post">
<table border="1" cellspacing="0" cellpadding="4">
<tr bgcolor="#F9F1E7">
<td><b>Nr. Buc</b></td>
<td><b>Carte</b></td>
<td><b>Pret</b></td>
<td><b>Total</b></td>
</tr>
<?php
for($i=0; $i<count($_SESSION['id_carte']); $i++)
{
if($_SESSION['nr_buc'][$i] !=0)
{
print '<tr><td><input type="text" name="noulNrBuc['.$i.']" size="1" value="'.$_SESSION['nr_buc'][$i].'"></td>
<td>'.$_SESSION['titlu'][$i].' de '.$_SESSION['nume_autor'][$i].' </td>
<td align="right">'.$_SESSION['pret'][$i].' lei </td>
<td align="right">'.($_SESSION['pret'][$i] * $_SESSION['nr_buc'][$i]).' lei </td>
</tr>';
$totalGeneral=$totalGeneral + ($_SESSION['pret'][$i] * $_SESSION['nr_buc'][$i]);
}
}
print '<tr><td align="right" colspan="3"> Total in cos </td><td align="right">'.$totalGeneral.' lei </td></tr>';
?>
</table>
<input type="submit" value="Modifica"><br><br>
Introduceti 0 pentru cartile ce doriti sa le scoateti din cos!
<h1>Continuare</h1>
<table>
<tr>
<td width="200" align="center"><img src="cos.jpg"><a href="index1.php">Continua cumparaturile</a></td>
<td width="200" align="center"><img src="casa.jpg"><a href="casa.php">Mergi la casa</a></td>
</tr>
</table>
</td>
<?php
include("page_bottom.php");
?>
My problem is every time I add a book to the cart, nothing is updated except for the quantity, so I have no author, title or price info, like so:

I'm just starting php coding and I can't figure out what's going on. Anyone willing to lend a helping hand? :shy:
I've used var_dump and it displays the following:
array(5) { ["id_carte"]=> array(1) { [0]=> string(1) "3" } ["nr_buc"]=> array(1) { [0]=> int(1) } ["pret"]=> array(1) { [0]=> string(0) "" } ["titlu"]=> array(1) { [0]=> string(0) "" } ["nume_autor"]=> array(1) { [0]=> NULL } }
So the session isn't getting any info except quantity and book id.