【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-change_quant.php,希望本篇文章对您学习有所帮助。
<?php
//
// change_quant.php:
// Change the quantity of an item in the shopping cart.
//
session_start();
if (session_is_registered('cart')) {
session_register('cart');
}
// Typecast to int, making sure we access the
// right element below
$i = (int)$_POST[id];
// Save the old number of products for display
// and arithmetic
$old_num = $_SESSION[cart][products][$i][1];
if ($_POST[quantity]) {
$_SESSION[cart][products][$i][1] = $_POST[quantity]; //change the quantity
} else {
unset($_SESSION[cart][products][$i]); // Send the product into oblivion
}
// Update the number of items
$_SESSION[cart][num_items] = ($old_num >$_POST[quantity]) ?
$_SESSION[cart][num_items] - ($old_num-$_POST[quantity]) :
$_SESSION[cart][num_items] + ($_POST[quantity]-$old_num);
?>
<html>
<head>
<title>
数量修改
</title>
</head>
<body>
<h1> 将数量: <?php echo $old_num; ?> 更改为
<?php echo $_POST[quantity]; ?></h1>
<a href="cart.php">返回</a> 商品列表页面.
</body>
</html>
上一篇:
change_password_form.php
下一篇:
面向android系统的测试工具_毕业论文