<?
switch ($action) {
case "removeall":
setcookie("allproduct");
break;
case "add":
$aproduct = "$allproduct:$item,$quantity,$price";
setcookie("allproduct","$aproduct",time()+6000);
break;
case "view":
$aproduct = $allproduct;
break;
case "remove":
$aproduct="";
$getline = preg_split("/[:]/",$allproduct);
for ($j=1;$j<count($getline);$j++) {
if ($removenumber <> $j) {
$aproduct = "$aproduct:$getline[$j]";
}
}
setcookie("allproduct","$aproduct",time()+6000);
break;
case "sendorderbymail":
mail("$tomail","Order from f2s php","$allproduct","From: $frommail");
$aproduct = $allproduct;
break;
}
echo "Action : $action<hr>";
if ($action == "add" || $action == "view" || $action == "remove") {
echo "<ol>";
$getline = preg_split("/[:]/",$aproduct);
for ($j=1;$j<count($getline);$j++) {
$rec = preg_split("/[,]/",$getline[$j]);
echo "<li>Product: $rec[0] Quantity: $rec[1] Price: $rec[2]";
}
echo "</ol>";
}
?>
จำนวน : 38 บรรทัด