<?php
session_start();
require_once("config.php");
$id=$_POST["id"];
$num=$_POST["goodsnum"];
$preg="/^[0-9]*[0-9]$|^[0-9]*[0-9]$/";
if($num==""){
 echo "<script>alert('数量不能为空!');history.back();</script>";
 exit;
}else if(!preg_match($preg,$num,$str)){
 echo "<script>alert('数量只能为正整数!');history.back();</script>";
 exit;
}
$arrayid=explode("@",$_SESSION["goodsid"]);
$arraynum=explode("@",$_SESSION["goodsnum"]);
$key=array_search($id,$arrayid);
$arraynum[$key]=$num;
$_SESSION["goodsnum"]=implode("@",$arraynum);
echo "<script>window.location.href='shopping_car.php';</script>";

$smarty->display("shopping_car.tpl");
?>
