I am currently in the middle of building an e-commerce system for my final year project at university and in my second year I can remember spending hours tapping away with tutorials I found on the internet that all seemed to require huge amounts of what I now see an unnecessary code.
This is the add to basket script i wrote this morning.
[code=php]<?php
require_once ‘includes/class_basket.php’;
session_start();
$basket = new basket($_SESSION[‘basket’]);
if ($_GET[‘item’])
{
$item = $_GET[‘item’];
$basket->items[$item]++;
$_SESSION[‘basket’] = $basket->items;
header(“Location: “.$_SERVER[‘HTTP_REFERER’]);
exit;
}
?>
11 lines of code (if you can even call it 11 lines).
It seems too good to be true is there anything critically flawed with my technique?
P.S. The value of $_GET[‘item’] is a unique product code to size and colour of the item