Notice: Undefined index: carrinho in
Pessoal,
Vê se alguém consegue observar essa notificação, pois já olhei e nada até agora?
Veja código mov_entrada.php
<?php
if(isset($_POST['incluir']))
{
$produtos = isset($_POST['produto']) ? $_POST['produto'] : '';
$valores = array($produtos);
if(!isset($_SESSION['carrinho'])){
$_SESSION['carrinho'] = array();
}
//adiciona produto
if(isset($_GET['acao'])){
//ADICIONAR CARRINHO
if($_GET['acao'] == 'add'){
$id = $valores[0][0];
$id = intval($valores[0][0]);
if(!isset($_SESSION['carrinho'][$id])){
$_SESSION['carrinho'][] = $valores;
}
}
}
}
//REMOVER CARRINHO
if(isset($_GET['acao'])){
if($_GET['acao'] == 'del'){
$id = intval($_GET['id']);
if(isset($_SESSION['carrinho'][$id])){
unset($_SESSION['carrinho'][$id]);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Itens dos Produtos</title>
</head>
<body>
<table>
<thead>
<tr>
<th width="80">Codigo</th>
<th width="400">Produto</th>
<th width="79">Quantidade</th>
<th width="89">Preço</th>
<th width="100">SubTotal</th>
<th width="64">Remover</th>
</tr>
</thead>
<form action="?cad=entradas_p1" method="post">
<tfoot>
<tr>
<td colspan="5"><input type="submit" value="Gravar" /></td>
</tr>
</tfoot>
<tbody>
<?php
if(count($_SESSION['carrinho']) == 0){
echo '<tr><td colspan="5">Não há produto no carrinho</td></tr>';
}else{
require("conexao/bdinc.php");
$total = 0;
foreach ($_SESSION['carrinho'] as $id => $valores) {
// $arr[3] será atualizado com cada valor de $arr...
$cod = $valores[0][0];
$nome = $valores[0][1];
$preco = str_replace(",",".",$valores[0][2]);
$qtd = $valores[0][3];
$sub = number_format($preco * $qtd, 2, ',', '.');
$total += $preco * $qtd;
$_SESSION['total'] = $total;
echo( '<tr>
<td>'.$cod.'</td>
<td>'.$nome.'</td>
<td align="center">'.$qtd.'</td>
<td align="right">R$'.$preco.'</td>
<td align="right">R$ '.$sub.'</td>
<td><a href="?cad=entradas&acao=del&id='.$id.'">Remove</a></td>
</tr>');
}
$total = number_format($total, 2, ',', '.');
echo '<tr>
<td colspan="4">Total</td>
<td align="right">R$ '.$total.'</td>
</tr>';
}
?>
</tbody>
</form>
</table>
</body>
</html>
A mensagem de notificação acusa uma variável indefinida nessa linha 69;
if(count($_SESSION['carrinho']) == 0){Discussão (7)
Carregando comentários...