PHP Shopping Cart Complete implementation Code _php instance

Source: Internet
Author: User
1. Product Display page

Copy CodeThe code is as follows:



























if (Trim ($info [tupian]== ""))
{
echo "No picture";
}
Else
{
?>
"Width=" "height=" border= "0" >
}
?>
" "
"Market Price: "
"Member Price: "
"> View Information"
"> Add to Cart"
"Quantity Remaining:
if ($info [shuliang]-$info [Cishu]) >0)
{
Echo ($info [shuliang]-$info [Cishu]);
}
Else
{
echo "Sold out";
}
?> "

}
?>

2. Document addgouwuche.php

Copy the Code code as follows:
Session_Start ();
Include ("conn.php");

if ($_session[username]== "")
{
echo "";
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; $i<>
{
if ($array [$i]== $id)
{
echo "";
Exit
}
}
$_session[producelist]=$_session[producelist]. $id. " @";
$_session[quatity]=$_session[quatity]. " 1@ ";

Header ("location:gouwu1.php");
?>

3. Document gouwu1.php

Copy the Code code as follows:
Session_Start ();
if ($_session[username]== "")
{
echo "";
Exit
}
?>
Include ("top.php");
?>

















3. Document gouwu2.php

Copy the Code code as follows:





















Consignee information




if ($_get[dingdanhao]!= "")
{$DD =$_get[dingdanhao];
Session_Start ();

$array =explode ("@", $_session[producelist]);
$sum =count ($array) *20+260;
echo "";

}
?>

4. Database configuration file conn.php

Copy the Code code as follows:
$conn =mysql_connect ("localhost", "root", "") or Die ("Database Server connection Error". Mysql_error ());
mysql_select_db ("Shop", $conn) or Die ("Database access Error". Mysql_error ());
mysql_query ("Set character set gb2312");
mysql_query ("Set names gb2312");
?>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.