Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\catalog\index.php:1) in C:\AppServ\www\catalog\index.php on line 5
Для session_start нужно подключать файл с подключением к БД?
index.php
<?php
include ('cart_fns.php');
session_start();
if(!isset($_SESSION['cart']))
{
$_SESSION['cart'] = array();
$_SESSION['total_items'] = 0;
$_SESSION['total_price'] = '0.00';
}
$view = empty($_GET['view']) ? 'index' : $_GET['view'];
include($_SERVER['DOCUMENT_ROOT'].'/catalog/views/layouts/shop.php');
cart.php //Корзина
<?php
$id = $_GET['id'];
$add_item = add_to_cart($id);
header('Location: index.php?view=product&id='.$id);
?>
<h2 align="center">Ваша корзина товаров</h2>
<form action="" method="post" id="cart-form">
<table id="mycart" align="center" cellspacing="0" cellpading="0" border="1" width="700" height="60">
<tr>
<th>Цена</th>
<th>Кол-во</th>
<th>Всего</th>
</tr>
<tr colspan="4">
<td align="center"></td>
<td align="center">Руб.</td>
<td align="center"><input type="text" size="2" name="" maxlength="2" value=""/> </td>
<td align="center">Руб.</td>
</tr>
</table>
<br />
<p class="total" align="center">Общая сумма заказа:<span class="product-price">Руб.</span></p><br />
<p align="center"><input type="submit" name="update" value="Обновить" /></p>
</form>
cart_fns.php
<?php
function add_to_cart($id)
{
if(isset($_SESSION['cart'][$id]))
{
$_SESSION['cart'][$id]++;
return true;
}
else
{
$_SESSION['cart'][$id] = 1;
return true;
}
return false;
}
?>