Php shopping cart & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-tra php shopping cart
Untitled Document
Homepage shopping basket history exit
$ Con = mysql_connect ("localhost", "root ","");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
$ Db_selected = mysql_select_db ("user", $ con );
$ SQL = "select * from produce"; // query all products
$ Rs = mysql_query ($ SQL, $ con); // run the SQL statement to obtain a result set.
While ($ row = mysql_fetch_array ($ rs) // traverses the result set
{
?>
Src = "images/ "Width =" 123 "height =" 121 "border =" 0 "/> |
Goods name: |
Goods price: |
& Pname = Echo $ row ["pname"]?> "> Purchase |
}
?>
------ Solution --------------------
What do you want to ask? There is an encoded text.
Isn't it easier for others to solve the problem for you to highlight the content with the corresponding source code?
------ Solution --------------------
$ Act = $ _ GET [act];
$ Product_id = $ _ GET [prcid];
If ($ act = "add ")
{
$ Cars_id = explode (",", $ _ COOKIE [buypro]);
// Echo"
";
//print_r($cars_id);
//echo"
";
// Exit;
Foreach ($ cars_id as $ pr_id)
{
If ($ pr_id = $ product_id)
{
Echo "script" alert ('you have purchased this item. Please check your 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 {
If ($ cars_id [$ I]! = $ Product_id)
{
$ Newid [] = $ cars_id [$ I];
$ Carcount [] = $ buycountary [$ I];
}
}