Home>Article>Backend Development> Code 1 about implementing shopping cart in php
This article introduces a shopping cart code implemented in PHP. The function implementation is relatively complete. It implements functions such as shopping cart, orderer information, membership price, etc. It is still good. Friends in need can refer to it
1. Product display page
| 【】 | |
【市场价:】 | ||
【会员价:】 | ||
【查看信息】 | ||
【放入购物车】 | ||
【剩余数量: 0) { echo ($info[shuliang]-$info[cishu]); } else { echo "已售完"; } ?>】 |
2. File addgouwuche.php
alert('请先登录后购物!');history.back();"; exit; } $id=strval($_GET[id]); $sql=mysql_query("select * from shangpin where id='".$id."'",$conn); $info=mysql_fetch_array($sql); if($info[shuliang]<=0) { echo ""; exit; } $array=explode("@",$_SESSION[producelist]); for($i=0;$ialert('该商品已经在您的购物车中!');history.back();"; exit; } } $_SESSION[producelist]=$_SESSION[producelist].$id."@"; $_SESSION[quatity]=$_SESSION[quatity]."1@"; header("location:gouwu1.php"); ?>
3. File gouwu1.php
alert('请先登录,后购物!');history.back();"; exit; } ?>
|
3. File gouwu2.php
|
|
4, database configuration file conn.php
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website !
Related recommendations:
Use PHP to implement the payment function of Alipay on the mobile APP
How to use PHP to implement quick money payment Function
The above is the detailed content of Code 1 about implementing shopping cart in php. For more information, please follow other related articles on the PHP Chinese website!