购物车基本文件实现
来源:互联网 发布:python 多进程 速度 编辑:程序博客网 时间:2024/04/30 01:08
注:文件名可自己更换。
1、 登录界面login.php
注册(insert into tb_user …)
登录(select * from tb_user…)
<?php
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
</head>
<body>
<form action="" method="post">
用户:<input type="text" name="user" /><br />
密码:<input type="password" name="pass" /><br />
保留:<input type="radio" name="expire" value="0" />不保留
<input type="radio" name="expire" value="1" />一天
<input type="radio" name="expire" value="30" />一月
<input type="radio" name="expire" value="365" />一年
</form>
</body>
</html>
2、 商品展示页面carlist.php
<?php
//本页面功能:显示购物车内的商品(商品名称、商品数量)
session_start();
echo "您已经选择的商品包括:<br>";
echo "<form action='' method='post'>";
//显示用户购买的商品
//包括功能:删除该商品
//修改商品的数量
//获取用户购买的信息$_SESSION,循环方式显示产品
foreach($_SESSION['car'] as $key=>$value){
echo "<input type='checkbox' name='list[]' value='{$key}'>";
echo "$key $value ";
//减少一件商品
echo '<a href="cardel1.php?list={$key}">-</a><br>';
echo "<a href='cardel2.php?list={$key}'>删除该商品</a><br>";
}
echo "<input type='submit' name='tijiao' value='结算'>";
echo "</form>";
?>
<a href="car.php">继续购买</a>
3、 商品一 car1.php
<?php
//检验$_POST相关信息
if(isset($_POST['submit'])){
print($_POST['car']);
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>日用百货</title>
</head>
<body>
<form action="car.php" method="post">
<input type="checkbox" name="car[]" value="毛巾">毛巾<br>
<input type="checkbox" name="car[]" value="牙膏">牙膏<br>
<input type="checkbox" name="car[]" value="牙刷">牙刷<br>
<input type="checkbox" name="car[]" value="香皂">香皂<br>
<input type="submit" name="submit" value="放入购物车">
</form>
</body>
</html>
4、 商品二 car2.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>家用电器</title>
</head>
<body>
<form action="car.php" method="post">
<input type="checkbox" name="car[]" value="电视">电视<br>
<input type="checkbox" name="car[]" value="电扇">电扇<br>
<input type="checkbox" name="car[]" value="冰箱">冰箱<br>
<input type="checkbox" name="car[]" value="电筒">电筒<br>
<input type="submit" name="submit" value="放入购物车">
</form>
</body>
</html>
5、 商品三 car3.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文化用品</title>
</head>
<body>
<form action="car.php" method="post">
<input type="checkbox" name="car[]" value="钢笔">钢笔<br>
<input type="checkbox" name="car[]" value="橡皮">橡皮<br>
<input type="checkbox" name="car[]" value="本子">本子<br>
<input type="checkbox" name="car[]" value="墨水">墨水<br>
<input type="submit" name="submit" value="放入购物车">
</form>
</body>
</html>
6、 添加商品 addcar.Php
7、 删除商品 cardel.php
<?php
//减少商品数量
session_start();//开启session环境
//接收目前数量
$_SESSION['cart'][$_GET['list']]--;
//销毁该商品
if($_SESSION['cart'][$_GET['list']]<=0){
unset($_SESSION['cart'][$_GET['list']]);
}
header("location:carlist.php");
?>
8、 清空购物车 carclear.php
9、 支付
- 购物车基本文件实现
- 购物车实现基本
- cookie购物车基本实现记录
- 电商项目购物车基本实现
- 加入购物车抛物线效果的基本实现(一)
- 基本实现京东购物车 mysql+php+html
- 购物车的基本方法
- 购物车的实现
- JSP 购物车实现
- profile实现购物车
- Ajax实现购物车
- HashTable实现购物车
- session实现购物车
- 购物车实现
- 购物车实现原理
- 实现购物车
- 购物车的实现
- 购物车的实现
- (整理)高速PCB设计理论基础
- 儿子终于出院了
- Copy-On-Write的原理及具体实现
- 今年IT业就业形势看好
- C#解析HTML
- 购物车基本文件实现
- 上市公司对ERP的要求
- findbugs 错误分析(1)
- c语言数组变量在内存中的连续分配情况
- 无线通信概述
- 购物车
- 士大夫
- SQL日期格式
- extjs 继承记录