Salve ragazzi, volevo esporvi un problema su u carrello che sto creando.
Non riesco e cancellare un articolo messo nel carrello tramite le sessioni.
Chi mi aiuta?
Grazie in anticipo.
La pagina shop.php è la lista dei prodotti,
carrello1.php è il carrello,
delpro.php è la pagina per cancellare un prodotto con unset ma non mi funziona.
Ecco il codice di carrello1.php:
Codice PHP:
                <?php
 $id
=$_GET["id"];
 
$op=$_GET["op"];
   if(
$id==""){
      print(
"<script language='javascript'>location.href='shop.php';</script>");
 } 
     
 
$sql="SELECT * FROM magazzino WHERE idProdotto={$id}";
 
$rs=mysql_query($sql);
 while(
$riga=mysql_fetch_array($rs)){
     
$foto=$riga["image"];
     
$descrizione=$riga["descrizione"];
     
$nomeprodotto=$riga["titolo"];
     
$prezzo=$riga["prezzo"];
     
$moltiplica=$riga["moltiplica"];
     
$confeTot=$riga["prezzo"]*$riga["moltiplica"];
     
$quantita=$riga["quantita"];
     
$note=$riga["note"];
 if(
$foto==""){
     
$foto="vuota.gif";
     
 }
 }
            
?>
 
<div class="foto" style="position:absolute; top:10px; left:10px;">[url="foto/<?php print($foto);?>"]" >[img]foto/<?php print($foto);?>[/img][/url]
</div>


<div style="width:200px; height:80px; position:relative; top:90px; left:10px;">
<span style="color:#669933; font-size:12px; font-weight:bold;">Nome prodotto</span>

<?php print($nomeprodotto);?>
<?php 
print($note);?>



<span style="color:#669933; font-size:12px; font-weight:bold;">Prezzo</span>

<?php print($prezzo);?> &euro;
<span style="font-size:10px;">(<?php print($prezzo/$moltiplica);?> &euro; cad.)</span>


<span style="font-weight:bold; color:red; font-size:13px;"></span>


</div>
<form name="form_carrello" id="form_carrello" method="post" action="carrello1.php?id=<?php print($id);?>&op=<?php print($op);?>">
<?php
    
if($_POST["campo_controllo"]=="ok"){
            
$c=false;
            
$varCarrello=$id."|".$_POST["pezzi"];
                if(
$_SESSION["carrello"]!=""){
            
$arrayCarrello1=$_SESSION["carrello"];
            
$conta=count($arrayCarrello1);
            for(
$y=0$y<$conta;$y++){
                
$varArray=$arrayCarrello1[$y];
                
$varArray=explode("|",$varArray);
                if((int) 
$varArray[0] == (int) $id){
                    
$c=true;
                    
$z = (int) $varArray[1];
                    
$sql="SELECT * FROM magazzino WHERE idProdotto={$id}";
                     
$rs=mysql_query($sql);
                     
$riga=mysql_fetch_array($rs);
                     if(
$op=="I"){
                     
$totale=$varArray[1]+ $_POST["pezzi"];
                     }else{
                         
$totale=$_POST["pezzi"];
                     }
                     if(
$riga["quantita"] < $totale){
                         print(
"<script language='javascript'>alert('Quantità eccedente');</script>");
                     }else{
                         if(
$op=="I"){
                    
$varArray[1] = $z $_POST["pezzi"];
                    }else{
                        
$varArray[1] =$_POST["pezzi"];
                    }
                    
$moltiplica=$riga["moltiplica"];
                
                    
$arrayCarrello1[$y]=$id."|".$varArray[1];
                     }
                }
            }
            
$_SESSION["carrello"]=$arrayCarrello1;
        }
        if(!
$c){
            
$arrayCarrello=array();
            if(
$_SESSION["carrello"]!=""$arrayCarrello=$_SESSION["carrello"];
            
$arrayCarrello[]=$varCarrello;
            
$_SESSION["carrello"]=$arrayCarrello;
        }
        
    }
?>
<div style="position:relative; left:10px; margin-top:150px;"> 
<?php
if($op=="I"){
?>

Scegli la quantità: <input name="pezzi" type="text" value="1" id="pezzi" size="5"/>
</div>



<div style="margin-left:5px;">
<input name="vai" type="button" id="vai" value="Conferma quantit&aacute;" onclick="javascript:controllo(<?php print($quantita);?>);"  style="cursor:pointer;"/>




<input name="Annulla" type="button" id="annulla" value="Torna alla lista" onclick="javascript:location.href='shop.php';"  style="cursor:pointer;"/>

<?php
}else{
    
$arrayCarrello1=$_SESSION["carrello"];
            
$conta=count($arrayCarrello1);
            for(
$y=0$y<$conta;$y++){
                
$varArray=$arrayCarrello1[$y];
                
$varArray=explode("|",$varArray);
                if((int) 
$varArray[0] == (int) $id){
                
$q=$varArray[1];
                
                }
            }
?>
Modifica la quantità: <input name="pezzi" type="text" value="<?php print($q);?>" id="pezzi" size="5"/>
</div>



<div style="margin-left:5px;">
<input name="vai" type="button" id="vai" value="Modifica quantit&aacute;" onclick="javascript:controllo(<?php print($quantita);?>);"  style="cursor:pointer;"/>



<input name="del" type="button" id="deli" value="Elimina dal carrello" onclick="javascript:location.href='delpro.php?id=<?php echo ??????????????? ?>';"  style="cursor:pointer;"/>



<input name="Annulla" type="button" id="annulla" value="Torna alla lista" onclick="javascript:location.href='shop.php';"  style="cursor:pointer;"/>



<?php
}
?>


<input type="hidden" name="campo_controllo" id="campo_controllo" value="" />
</div>
</form>
nel pulsante Elimina carrello che devo passare?????