PDA

View Full Version : new LoadVars(); and php shopping cart



RyanGus
January 2nd, 2010, 01:45 AM
hello, im building a shopping cart with PHP, Flash, MySql. the problem is when i try to add items to the cart they overwrite each other.

im sending the variables via loadVars from the flash to the PHP and everything is working great till i add a new item... the new item overwrite the old one.. this is my php script.....



<?php
session_start();

extract($_REQUEST);

mysql_connect("localhost","root","*********");
mysql_select_db("menosesmas_vinyl");

if(!isset($cantidad)){$cantidad=1;}

$qry=mysql_query("select * from vinyllaves where id='".$id."'");
$row=mysql_fetch_array($qry);

if(isset($_SESSION['carro']))
$carro=$_SESSION['carro'];


$model = $HTTP_POST_VARS['model'];
$precio = $HTTP_POST_VARS['precio'];
$color = $HTTP_POST_VARS['colorname'];
$cantidad = $HTTP_POST_VARS['cantidad'];


$carro[md5($id)]=array('identificador'=>md5($id),'cantidad'=>$cantidad,'model'=>$model,'precio'=>$precio,'id'=>$id,'colorname'=>$color);

$_SESSION['carro']=$carro;

header("Location:vercarrito.php?".SID);
?>

RyanGus
January 2nd, 2010, 01:56 AM
the kind of cart im trying to accomplish is one like this...

http://www.decoratupared.com