How to write PHPcookie + shopping cart ?? I will not write it here when I create a website to make a shopping cart !! Please refer to the highly handwritten code !! Thank you.
Reply to discussion (solution)
The one that cannot store cookies, and the user will log on to the favorites next time to find the items in the shopping cart.
Ajax + database storage content.
I am also in need of shopping cart information, 2 floor said AJax + database is how to achieve, if you have the source code to share... thank you!
"; //print_r($cars_id);//echo"
"; // Exit; foreach ($ cars_id as $ pr_id) {if ($ pr_id = $ product_id) {echo" script alert ('you have purchased this product, check the shopping cart! '); Location. href = 'Car. php'; script "; exit; }}if (empty ($ _ COOKIE [buypro]) {setcookie (" buypro ", $ product_id, time () + 3600); setcookie ("buycount", "1", time () + 3600);} else {$ newpro = $ _ COOKIE [buypro]. ",". $ product_id; $ newcount = $ _ COOKIE [buycount]. ",". "1"; setcookie ("buypro", $ newpro, time () + 3600); setcookie ("buycount", $ newcount, time () + 3600 );}} // delete if ($ act = "del") {$ buy = $ _ COOKIE [buypro]; $ cars_id = explode (",", $ buy ); $ buycountary = explode (",", $ _ COOKIE [buycount]); $ newid = array (); $ carcount = array (); for ($ I = 0; $ I
Learning
Share you a full set of points, which are not enough.
// Index. php
"Width =" 123 "height =" 121 "border =" 0 "/> |
Goods name: |
Goods price: |
& Pname = "> Purchase |
// Conn. php
// Car. php
Item ID |
Item Quantity |
Unit Price |
Total price |
Delete |
|
|
|
|
"> Delete |
|
|
Total price |
|
S |
Submit the order // return to the home page // buy. php
$ Pid, "price" = >$ price, "num" => 1) ;}} else {$ arr [$ pid] = array ("pid" => $ pid, "price" => $ price, "num" => 1);} $ _ SESSION ["mycar"] = $ arr; // after the purchase, put this array into the session again, and you can see this sessionob_clean (); // clear the cache header ("location: car. php "); // jump to the shopping cart page (car. php)?>
It may not be very powerful, but it is a basic skill. You can modify it as required.
How to write thinkPHP shopping cart code
Learning
A user who has not logged on to the shopping cart stores items in cookies and has logged on to the database