Category Archives: PHP

Create your databases first

here is your source code for your online shopping cart

— phpMyAdmin SQL Dump
— version 2.10.3
http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Jun 23, 2013 at 10:26 AM
— Server version: 5.0.51
— PHP Version: 5.2.6

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `online_stores`

— ——————————————————–


— Table structure for table `inventory`

CREATE TABLE `inventory` (
  `storeID` varchar(10) default NULL,
  `productID` varchar(10) NOT NULL,
  `name` varchar(100) default NULL,
  `description` varchar(200) default NULL,
  `price` float default NULL,
  PRIMARY KEY  (`productID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


— Dumping data for table `inventory`

INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE001’, ‘Jamaican Blue Mountain Coffee’, ‘This extraordinary coffee, famous for its exquisite flavor and strong body, is grown in teh majestic Blue Mountain range in Jamaica. Weight: 1 pound.’, 22.95);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE002’, ‘Blue Grove Hawaiian Maui Premium Coffee’, ‘This delightful coffee has an aroma that is captivatingly rich and nutty with a faint hint of citrus. Weight: 1 pound.’, 18.89);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE003’, ‘Sumatra Supreme Coffee’, ‘One of the finest coffees in the world, medium roasted to accentuate its robust character. Weight: 5 pounds.’, 29.95);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE004’, ‘Pure Kona Coffee’, ‘Grown and processed using traditional Hawaiian methods, then roasted in small batches to maintain peak freshness and flavor. Weight: 10 ounces.’, 21.45);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE005’, ‘Guatemala Antigua Coffee’, ‘An outstanding coffee with a rich, spicy, and smokey flavor. Weight: 10 ounces.’, 7.5);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE001’, ‘Set of four Shaker ladderback chairs’, ‘From the early 1800”s, this set of four matching ladderback chairs in the traditional Shaker style have been in the same family for eight generations. All four have the original rush seats (one slight’, 12000);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE002’, ‘Hepplewhite Secretary’, ‘All original glass and hardware. Made of mahogany, brass and glass. All decorative inlays and finials intact. Some minor condition issues (bumps and nicks) that add to, rather than detract from, the h’, 19500);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE003’, ‘Empire Sideboard’, ‘Mahogany primary with cypress secondaries. Three drawers above three cupboards. From an ante-bellum Louisiana estate. Excellent condition.’, 3450);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE004’, ‘Gothic Bookcase’, ‘All walnut with blocked corners and glazed sliding doors. This unit has a dentillated pediment and a molded cornice. Wonderful condition, made in New York in the early 1800”s’, 14500);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE005’, ‘Federal Dining Table’, ‘Mahogany two-pillar dining table. Each urn form column rests on three molded sabre legs with brass paws. Two removable leaves are still in place. Excellent condition, minimal wear.’, 4500);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT001′, ’32GB High Speed microSD card’, ‘With enough speed for high-speed digital cameras and enough storage space for nearly 50 CDs, this card is perfect for your multimedia devices.’, 123.99);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT002’, ‘3-in-1 4GB USB 2.0 Flash Drive Pen and Laser Pointer’, ‘Carry it all in a single device. The bottom is a ball-point pen, the top is a laser pointer, and inside is a 4GB USB flash drive.’, 14.99);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT003’, ‘Bluetooth Bracelet with OLED Display’, ‘Pair this bracelet to your bluetooth-enabled phone, and ringtones are a thing of the past. When a call is received, the bracelet vibrates and the incoming caller ID displays on the OLED screen.’, 49);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT004’, ‘Fitness Watch with Heart Rate Monitor’, ‘Not only does this device time your workout, it monitors your heart rate. Using ANT+ technology, the device can pair with your exercise equipment or an optional foot pod to track your progress. All of’, 149);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT005’, ‘Solar Charging Backpack’, ‘Recharge your phone, mp3 player, or handheld device while on the go with this stylish and roomy backpack. The exterior features a solar cell that charges a built-in rechargeable battery. Connectors ar’, 179.95);

— ——————————————————–


— Table structure for table `store_info`

CREATE TABLE `store_info` (
  `storeID` varchar(10) NOT NULL,
  `name` varchar(50) default NULL,
  `description` varchar(200) default NULL,
  `welcome` text,
  `css_file` varchar(250) default NULL,
  `email_address` varchar(100) default NULL,
  PRIMARY KEY  (`storeID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


— Dumping data for table `store_info`

INSERT INTO `store_info` VALUES (‘COFFEE’, ‘Gosselin”s Gourmet Coffee’, ‘Specialty coffees made from the world”s finest beans’, ‘Welcome to Gosselin”s Gourmet Coffee. Here you will find many of the world”s finest gourmet coffees. Our blends are hand-selected from the most unique and flavorful beans, each custom-roasted to enhance the distinct flavor. Whether you desire a dark, medium or light roast, you will find a special treat on our list.’, ‘GosselinGourmet.css’, ‘ggcoffee@example.com’);
INSERT INTO `store_info` VALUES (‘ANTIQUE’, ‘Old Tyme Antiques’, ‘Furniture from America”s Colonial and Post-war periods’, ‘At Old Tyme Antiques, we search for the finest examples of Early American furniture. Our appraisers and researchers have researched each and every one of our items, and all have a certified provenance. Any restoration work has been performed by our expert restorers, and is fully documented. We are constantly searching estate sales for new items. If you have an item, we would be glad to appraise it for you, or even sell it on consignment.’, ‘OldTymeAntiques.css’, ‘antique1783@example.net’);
INSERT INTO `store_info` VALUES (‘ELECBOUT’, ‘Electronic Boutique’, ‘Computer accessories and peripheral devices’, ‘Want the coolest high-tech gadgets around? You”ve come to the right place. We offer USB drives, media cards, and other electronic devices to enhance your digital life.’, ‘ElectronicsBoutique.css’, ‘usb4sale@example.org’);

Use PHP create an program an online order form–continue

Use PHP create  an program an online order form

you could see what it look like,

http://www.sandywebdesigner.com/index.php?section=Final-Project

http://www.sandywebdesigner.com/con_str/stores/GosselinGourmetCoffee.php

http://www.sandywebdesigner.com/con_str/stores/OldTymeAntiques.php

http://www.sandywebdesigner.com/con_str/stores/ElectronicsBoutique.php

the 3 order form just use the same class, you don’t to rewrite it, just change the storeID, you could use for any shopping cart.

the following post i will write the source code.

create a php page with in paypal button and link–this just continue with previous page

<?php
echo “<h1>Welcome to Bazaar online shop</h1>”;
include(“inc_db.php”);//connect to database newsletter
if($DBConnect)
{
$table = “products”;
$query = “select * from $table”;
$result = @mysql_query($query,$DBConnect);
echo “<table width = ‘80%’ border = ‘1’>”;
echo “<tr><th>Name</th><th>Cost</th><th>Image</th><th>Description</th><th>Add to Cart</th><th>Go Pay</th></tr>”;
while($row = mysql_fetch_assoc($result))
{
echo “<tr><td>$row[Name]</td><td>$row[Cost]</td>”;
echo “<td><img src =’images/”.$row[‘Image’].”‘/></td><td>$row[Description]</td><td>”;
echo “<form action=’https://www.paypal.com/cgi-bin/webscr&#8217; method =’post’>”;
echo “<input type=’hidden’ name=’cmd’ value=’_cart’>”;
echo “<input type=’hidden’ name=’business’ value=’youremail@host.com’>”;
echo “<input type=’hidden’ name=’item_name’ value='”.$row[‘Name’].”‘>”;
echo “<input type=’hidden’ name=’amount’ value='”.$row[‘Cost’].”‘>”;
echo “<input type=’hidden’ name=’currency_code’ value=’AUD’>”;
echo “<input type=’hidden’ name=’add’ value=’add’>”;

echo “<input type=’hidden’ name=’bn’ value=’PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest’>”;
echo “<input type=’image’ src = ‘https://www.paypalobjects.com/en_AU/i/btn/btn_cart_LG.gif&#8217; border=’0′ name=’submit’ alt=’PayPal – The safer,easier way to pay online.’>”;
echo “<img alt=” border=’0′ src=’https://www.paypalobjects.com/en_AU/i/src/pixel.gif&#8217; width=’1′ height=’1′>”;
echo “</form></td>”;
echo “<td><form action=’https://www.paypal.com/cgi-bin/webscr&#8217; method =’post’>”;
echo “<input type=’hidden’ name=’cmd’ value=’_xclick’>”;
echo “<input type=’hidden’ name=’business’ value=’youremail@host.com’>”;
echo “<input type=’hidden’ name=’item_name’ value='”.$row[‘Name’].”‘>”;
echo “<input type=’hidden’ name=’amount’ value='”.$row[‘Cost’].”‘>”;
echo “<input type=’hidden’ name=’currency_code’ value=’AUD’>”;
echo “<input type=’hidden’ name=’bn’ value=’PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest’>”;
echo “<input type=’image’ src = ‘https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif&#8217; border=’0′ name=’submit’ alt=’PayPal – The safer,easier way to pay online.’>”;
echo “<img alt=” border=’0′ src=’https://www.paypalobjects.com/en_Au/i/src/pixel.gif&#8217; width=’1′ height=’1′>”;
echo “</form></td></tr>”;

}
echo “</table>”;
mysql_free_result($result);
mysql_close($DBConnect);

}
?>

a paypal shopping cart with php here is the source code for you catalog–continue

first, create your catalog and product database, here is the source code:

— phpMyAdmin SQL Dump
— version 2.10.3
http://www.phpmyadmin.net

— Host: localhost
— Generation Time: May 24, 2013 at 02:43 PM
— Server version: 5.0.51
— PHP Version: 5.2.6

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `bazaar`

CREATE DATABASE `bazaar` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `bazaar`;

— ——————————————————–


— Table structure for table `categories`

CREATE TABLE `categories` (
`CatID` int(11) NOT NULL auto_increment,
`Name` varchar(50) NOT NULL,
PRIMARY KEY  (`CatID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;


— Dumping data for table `categories`

INSERT INTO `categories` VALUES (1, ‘Bazaar Ceramics Catalogue’);

— ——————————————————–


— Table structure for table `products`

CREATE TABLE `products` (
`ProdID` int(11) NOT NULL auto_increment,
`CartID` int(11) NOT NULL,
`Name` varchar(50) NOT NULL,
`Cost` decimal(8,2) NOT NULL,
`Image` varchar(50) NOT NULL default ‘NoImage.jpg’,
`Description` varchar(250) default NULL,
PRIMARY KEY  (`ProdID`),
KEY `CartID` (`CartID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;


— Dumping data for table `products`

INSERT INTO `products` VALUES (1, 1, ‘Copper Red Dish 001’, 450.00, ‘bcpot002_smaller.jpg’, ‘Shallow Copper Red dish form showing distinctive qualities of this traditional reduction fired glaze.  Fired to 1300 degrees’);
INSERT INTO `products` VALUES (2, 1, ‘Copper Red Bottle 001’, 550.00, ‘bcpot003_smaller.jpg’, ‘Copper Red bottle form.  Reduction fired to 1300 degrees’);
INSERT INTO `products` VALUES (3, 1, ‘Chun bowl 001’, 350.00, ‘bcpot006_smaller.jpg’, ‘Blue Chun bowl with tea stain rim over terracotta.  Fired to 1300 degrees’);
INSERT INTO `products` VALUES (4, 1, ‘Moonscape bowl 001’, 320.00, ‘bcpot009_smaller.jpg’, ‘High Calcium bowl with white glaze over blue slip.  Fired to 1280 degrees’);
INSERT INTO `products` VALUES (5, 1, ‘Crystalline bowl 001’, 250.00, ‘bcpot013_smaller.jpg’, ‘Blue Green Crystalline glaze.  Narrow-foot bowl with clear glaze outside.  Fired to 1300 degrees’);
INSERT INTO `products` VALUES (6, 1, ‘Carved vase form 001’, 450.00, ‘bcpot014_smaller.jpg’, ‘Carved Iron stoneware vase form.  Oxidation lustre on rim.  Fired to 1280 degrees’);
INSERT INTO `products` VALUES (7, 1, ‘Carved vase form 002’, 450.00, ‘bcpot016_smaller.jpg’, ‘Carved dry matt calcium vase form.  Fired to 1280 degrees’);
INSERT INTO `products` VALUES (8, 1, ‘Carved Bottle form 001’, 600.00, ‘bcpot018_smaller.jpg’, ‘Carved dry matt calcium bottle form.  Lustre rim.  Fired to 1280 degrees’);
INSERT INTO `products` VALUES (9, 1, ‘Dry earth vase form 001’, 500.00, ‘bcpot012_smaller.jpg’, ‘Vase form.  White slip over earthenware clay. Fired to 1000 degrees’);
INSERT INTO `products` VALUES (10, 1, ‘Carnivale cup and saucer 001’, 150.00, ‘bcpot008_smaller.jpg’, ‘ Cup and Saucer with Carnivale design.  Coloured slips under clear glaze.  Earthenware’);

use php process a web form feedback-insert data-continue1

you already  had a page collect information from use input, and build a page connect to your serves databases, here is the page use for process the data, (insert the information to your databases)

here is your process_chinese_zodaic.php page sourse code;

<?php
$sender = trim($_POST[‘fname’]);
$feedback =trim($_POST[‘feedback’]);
$agree = $_POST[‘agree’];
$submit = $_POST[‘submit’];
$error=0;

if(empty($sender)||empty($feedback))
{
echo “Your must write your first name,last name,feedback”;
++$error;
}
if($agree == 1)
{
$agree = “N”;

}
else
{
$agree = “Y”;
}
if($error == 0)
{
include(“inc_connect.php”);
if($DBConnect)
{
$table = “zodiacfeedback”;
$data = date(“Y-m-d”);
$time = date(“H:i:s”);
$query = “insert into $table(message_date,message_time,sender,message,public_message)values(‘$date’,’$time’,’$sender’,’$feedback’,’$agree’)”;
$result = @mysql_query($query);
if(!$result)
{
echo “<p>unable to insert the values “. mysql_error().”</p>”;
}
else
{
echo “<p>”.htmlentities($sender).”,Thanks you for giving us feedback.</p>”;
echo “<p><a href=’view_zodiac_feedback.php’>View all of the feedback</a></p>”;

}
mysql_close($DBConnect);
}

}

?>

use php process a web form feedback–continue

since you got a form collect your information , so now you need create a database

here it is , you could save this as inc_connect.php

<?php
$db_name = “chinese_zodiac_database”;
$DBConnect = mysql_connect(“severname”,”usename”,”password”);
if (!$DBConnect)
{
echo “<p>unable to connect to the database server “.mysql_error().”</p>”;
}
else
{
$db = mysql_select_db($db_name);
if(!$db)
{
echo “<p>unable to connect to the database server “.mysql_error().”</p>”;
mysql_close();
$DBConnect = false;
}

}

?>