This article introduces a php shopping cart code, which provides complete functions, such as shopping cart, ordering person information, and membership price. It is still good. If you need it, refer to section 1. Product Display page
The Code is as follows:
If (trim ($ info [tupian] = "")) { Echo "no image "; } Else { ?> "Width =" 130 "height =" 100 "border =" 0 "> } ?>
|
|
【 ] |
|
[Market price: ] |
|
[Member price: ] |
|
["> View information] |
|
["> Add to shopping cart] |
|
[Remaining quantity: If ($ info [shuliang]-$ info [cishu])> 0) { Echo ($ info [shuliang]-$ info [cishu]); } Else { Echo "sold out "; } ?>] |
}
?>
2. File addgouwuche. php
The Code is as follows:
Session_start ();
Include ("conn. php ");
If ($ _ SESSION [username] = "")
{
Echo "script" alert ('Please log on first and then shop! '); History. back (); script ";
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 "script" alert ('this item has been sold out! '); History. back (); script ";
Exit;
}
$ Array = explode ("@", $ _ SESSION [producelist]);
For ($ I = 0; $ I {
If ($ array [$ I] ==$ id)
{
Echo "script" alert ('this item is already in your shopping cart! '); History. back (); script ";
Exit;
}
}
$ _ SESSION [producelist] =_ _ SESSION [producelist]. $ id ."@";
$ _ SESSION [quatity] =_ _ SESSION [quatity]. "1 @";
Header ("location: gouwu1.php ");
?>
3. File gouwu1.php
The Code is as follows:
Session_start ();
If ($ _ SESSION [username] = "")
{
Echo "script" alert ('Please log on first and then shop! '); History. back (); script ";
Exit;
}
?>
Include ("top. php ");
?>
3. File gouwu2.php
The Code is as follows: