Webshop Cookie..
Hejsa, der ude..Jeg har leget lidt med en lille simple webshop.. Den skal bruges til tøj..
Derfor skal der kunne vælges farve og størrelse.. Det har jeg problemer med.. Der skal vælges et tal, fra en form.. Og gemmes i en cookie.. Her er lidt kode:
////// Vis_vare.php
<form name="vare_id" action="phpCart_manage.php?act=add&pid=<?php print"$row[id]" ?>&vare_id=$vare_id">
<select name="vare_id">
<option value="conboy_orang">Orange</option>
<option value="conboy_gron">Grøn</option>
<option value="conboy_brun">Brun</option>
</select>
<input type="submit">
</form>
///// PhpCart_manage.php
<?
session_start();
?>
<?
ob_start();
?>
<?
if($send){
print"<meta http-equiv='refresh' content='1;URL=betal.php'>BETALNING!!!
";
}
// UPDATE BASKET QUANTITY
if (isset($_POST["UpdateChg"])) {
session_start();
include "functions_cart.php";
$i = 0;
$size = count($_POST["eid"]);
for ($i = 0; $i <= $size-1; $i++) {
// call remove bad characters function
$badsymbols = array(" ","-","+","*","/",".");
$_POST["newquan"][$i] = str_replace($badsymbols,"", $_POST["newquan"][$i]);
if (is_numeric($_POST["newquan"][$i])) {
// if any quantity's equal 0 then remove from cart
if ($_POST["newquan"][$i] == 0) {
unset($_SESSION["cart"][$_POST["eid"][$i]]);
}
// update quantity in cart.
if (array_key_exists($_POST["eid"][$i], $_SESSION["cart"])) {
add_item_to_cart($_POST["eid"][$i], $_POST["newquan"][$i]);
}
} // END IF NUMERIC
}
header ("location:".$_SERVER['HTTP_REFERER']);
} // END BASKET QUANTITY
// TEXT LINKS
if (isset($_GET["act"])) {
// ADD ITEM!
if ($_GET["act"] == "add") {
session_start();
include "functions_cart.php";
//unserialize($_SESSION["cart"]);
if (!isset($_SESSION["cart"])) {
// add first item
add_item_to_cart($_GET["pid"],1);
session_register(pid);
} else if (array_key_exists($_GET["pid"], $_SESSION["cart"])) {
// add 1 to quantity if item in cart already
add_item_to_cart($_GET["pid"],++$_SESSION["cart"][$_GET["pid"]][1]);
} else {
// add any other items after first item
add_item_to_cart($_GET["pid"],1);
}
}
// DELETE ITEM!
if ($_GET["act"] == "del") {
include "functions_cart.php";
del_item($_GET["pid"]);
}
} // END ISSET
?>
<?
ob_end_flush();
?>