Jump to content

Recommended Posts

I have been struggling with understanding sessions and I think I finally understand it, but I want to make sure.  Say you had a catalog page with products and A quantity text field.  the session code would be something like this:

 

session_start();
$_SESSION ['product_id']=$product_id;
$_SESSION ['quantity']=$quantity;

that code would go on the catalog page and the checkout page, right?  The only thing I'm not quit clear on is what goes in the []

Link to comment
https://forums.phpfreaks.com/topic/248595-understanding-sessions/
Share on other sites

Maybe something like:

 

$_SESSION['cart'][$product_id] = $quantity;

 

Then you could grab the product_id from the key and the quantity from the value.  There's tons of ways to do it, but you are most likely going to want the ability to have multiple items I would assume.

so [$Product_id]wouldn't grab all  the products?

Maybe something like:

 

$_SESSION['cart'][$product_id] = $quantity;

 

Then you could grab the product_id from the key and the quantity from the value.  There's tons of ways to do it, but you are most likely going to want the ability to have multiple items I would assume.

It seems that you think that $_SESSION is some type of special variable that has special actions based on what you do. it is like every other array you would use in PHP, the only difference being it is SUPER GLOBAL, and thus available in all scopes at all times, assuming that you use the session start() statement.

 

Its unclear what your asking in the OP. Are you asking if what you posted is valid? Yes it is, but begs the question of where your $product_id and $quantity variable come from. Are they assigned earlier? What is their value?

 

As far as your question to "I don't know what goes in the [] part" what thorpe says is correct. To explain further, that is the key you assign to the value of that particular element in the array. Its the same as any other associative array. You of course want to use relevant values for the keys.

 

Now, back to your original code snippet. Assuming that you want to store the values that the user entered into the product field and quantity field that you post via a form (I will assume the method is post in my example) you could store the values the user entered in session data via

$_SESSION['product_id'] = $_POST['product_id'];
$_SESSION['quantity'] = $_POST['quantity'];

 

This of course assumes you have a form that the user enters data to. You could also pas these values through $_GET or a cookie or whatever means you choose. But you would have the change the session assignment accordingly.

 

Perhaps if you could give a more concrete example of what you are trying to accomplish with sessions, i can give a more straightforward answer

I think I'm starting to get it but I need a little more clarification.  I have attached a map of the product .  Say I wanted the quantity to go to the checkout page the code would look something like this:

 

if(isset($_POST[$quantity])) {  //if there is a variable in the quantity textbox start session 
        session_start();
      $_SESSION['quantity'] = $_POST['quantity']; //not understanding this line 
      }

 

[attachment deleted by admin]

Maybe this sample will help.  The "name" for each item in the form is the product id and the customer enters how many they would like.  In stead of an input type "text" you could use a selection drop down.  Just be sure the "name" is the product id.

<?php
IF (isset($_POST['submit'])){
$cart=array();
foreach ($_POST as $key => $value){
IF ($value!="Add to Cart" && !empty($value)){
$cart[$key] = $value;
}// IF ($value!="Add to Cart")
}// foreach ($_POST as $key => $value)
session_start();
$_SESSION['cart']=$cart;
print_r($_SESSION['cart']);
}
?>
<html>
<body>
<form method="post" action="sample.php">
<table border=0 summary="producttable">
<tr>
	<td>Product One</td>
	<td><input style="width:25px" type="text" name="1" /></td>
</tr>
<tr>
	<td>Product Two</td>
	<td><input style="width:25px" type="text" name="2" /></td>
</tr>
<tr>
	<td colspan="2"><input type="submit" name="submit" value="Add to Cart" /></td>
</tr>
</table>
</form>
</body>
</html>

Sure.  The user selects the items they want and these values are stored in a session.  Where you go depends on you.  Say they need to create an account or log in.  While the user is doing these other tasks, the cart session values are still saved and can be used at say Checkout time after the user has logged in.  As you can see by the print_r line, the session holds the product id as the "key" and the quantity as the "value.

I'm sorry, but I need a  little more help.  I added a foreach loop to the checkout page, but the treats aren't transferring to the checkout page.  Some help would be much appreciated. 

 

treats.php

<?php
require_once("functions.php"); 
IF (isset($_POST['submit'])){
$cart=array();
foreach ($_POST as $key => $value){
IF ($value!="Add to Cart" && !empty($value)){
$cart[$key] = $value;
}// IF ($value!="Add to Cart")
}// foreach ($_POST as $key => $value)
session_start();
$_SESSION['cart']=$cart;
print_r($_SESSION['cart']);
}
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
td {
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #30C;
border-right-color: #30C;
border-bottom-color: #30C;
border-left-color: #30C;
}
#productCatalog {
width:400px;   
margin-right: auto;
margin-left: auto;
}
</style>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
</head>

<body>

<?php
logo();
navBar();
echo "<div id=\"productCatalog\">";
echo "<form action=\"checkOut.php\" method=\"post\" name=\"catalog\">";
  
DatabaseConnection();  

  $query = "SELECT * FROM treats"; 
        $result_set = mysql_query($query) or die(mysql_error());
$i = 0;

        echo "<table>";
        while ($row = mysql_fetch_array($result_set))
        {
	echo"<tr><td width=\"2s00px\"><img src=\"{$row['product_pic']}\" /></td><td width=\"200px\">{$row['product_title']}.<br /><br />{$row['product_Description']}.<br /> Price:  \${$row['price']}.<br /><br />Quantity <input name=\"quantity\" type=\"text\" size=\"2\" /></td></tr>";
        }
	echo "<tr>"; 
		echo "<td><input name=\"submit\" type=\"button\" value=\"Proceed to Checkout\" />"; 
	echo "</table>";    
	echo "</form>";
echo "</div>";
footer();
?>
</body>
</html>

checkouut.php

<?php
require_once("functions.php");
DatabaseConnection(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ordering doggy treats</title>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#order {

margin-right: auto;
margin-left: auto;
}
.orderRow{
padding-bottom: 50px;
}
h2 {
text-align: center;
}

</style>
</head>
<body>
<?php
//error code 
navBar();
echo <<<HEREDOC
<div id="logo"><img src="assets/logo.gif" width="182" height="123" alt="logo" /></div>
<table id="order">  
<form action="checkOut.php" method="post" name="checkOut">

<caption><h2>Customer Information </h2> </caption>
<tr class = "orderRow">
<td> First Name:<br />
     <input name="fname" type="text" size="10" maxlength="20" />  		  
    </td>  
<td> Last Name: <br />
     <input name="lname" type="text" size="10" maxlength="20" /> 
</td>
<td>    Address: <br />
         <input name="address " type="text"  size="25" /> 
</td>  
</tr>
<tr class = "orderRow">
	<td>  City:  <br />
      <input name="city " type="text" size="15" maxlength="20" /> 
</td>
<td>   State:   <br />
          <select name = "state">  <option selected value ="Please choose a state"/>
		Please choose a state</option>
		<option value = "AL" />AL</option>
		<option value = "AK" />AK</option>
		<option value = "AR" />AR</option>
		<option value = "AZ" />AZ
		<option value = "CA" />CA
		<option value = "CO" />CO
		<option value = "CT" />CT
		<option value = "DE" />DE
		<option value = "DC" />DC
		<option value = "FL" />FL
		<option value = "GA" />GA
		<option value = "HI" />HI															
		<option value = "IA" />IA
		<option value = "ID" />ID
		<option value = "IL" />IL
		<option value = "IN" />IN
		<option value = "KS" />KS
		<option value = "KY" />KY
		<option value = "LA" />LA
		<option value = "MA" />MA
		<option value = "ME" />ME
		<option value = "MD" />MD
		<option value = "MI" />MI
		<option value = "MN" />MN
		<option value = "MO" />MO
		<option value = "MS" />MS
		<option value = "MT" />MT
		<option value = "NC" />NC
		<option value = "ND" />ND
		<option value = "NE" />NE
		<option value = "NH" />NH
		<option value = "NJ" />NJ
		<option value = "NM" />NM
		<option value = "OH" />OH
		<option value = "OK" />OK
		<option value = "OR" />OR
		<option value = "PA" />PA
		<option value = "RI" />RI
		<option value = "SC" />SC
		<option value = "SD" />SD
		<option value = "TN" />TN
		<option value = "TX" />TX
		<option value = "UT" />UT
		<option value = "VA" />VA
			<option value = "VT" />VT
		<option value = "WA" />WA
		<option value = "WI" />WI
		<option value = "WV" />WV
		<option value = "WY" />WY
		</select> 
  </td>   
<td>  Zip Code:<br />
          <input name="zipcode" type="text" size="5" maxlength="5" /> 
</td>  
</tr>  
<tr class = "orderRow">
<td> Phone  <br />  Please include area code <br />  
    <input name="phone" type="text" size="13" maxlength="13" /> 
</td>
<td>  Fax:<br />   
    <input name="" type="text" size="13" maxlength="13" /> 
    </td>
<td>   Email: <br />  
<input name="email " type="text" size="15" maxlength="30" />
</td>
</tr>
<tr class = "orderRow">  
     <td>   Please choose method of payment: <br /> 
Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td>
</tr>
<tr>
<td colspan = "6">	 <h2>  Pet Information </h2></td>
</tr>
<tr>
  <td>  Name: <br /> 
      <input name="petName" type="text" size="10" maxlength="20" /> 
  </td>  
<td>   Age: <br />
<select name="age">  
HEREDOC;
  for ($age =1; $age <=20; $age ++)
	{
	print "<option value=\"age\">  $age</option>"; 
}
echo <<<HEREDOC
</select>
</td>   
<td>   Breed:<br />
<select name = "breed">  <option selected value ="Please choose a breed"/>
		Please choose a breed
		    <option value = "I don't know" />I don't know 
			<option value = "Affernpincher" />Affernpincher
			<option value = "Afghan Hound" />Afghan Hound 
			<option value = "Airedale Terrier" /> Airedale Terrior
			<option value = "Akita" />  Akita 
			<option value = "Alaskan Malamute" />  Alaskan Malamute
			<option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog
			<option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo 		                                 Dog
			<option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog
			<option value = "American Foxhound" />  American Foxhound
			<option value = "American Staffordshire Terrier" />  American Staffordshhire                                 Terrier
			<option value = "American Water Spaniel" /> American Water Spaniel
			<option value = "Australian Shepherd Dog"/>  Anatolian Shepherd Dog 
			<option value = "Australian Cattle Dog"/>  Australian Cattle Dog
			<option value = "Australian Shepherd"/>  Australian Shepherd 
			<option value = "Australian Terrier" />  Australia Terrier
			<option value = "Basenji" />  Basenji
			<option value = "Basset Hound" />  Basset Hound 
			<option value = "Beagle" />  Beagle
			<option value = "Bearded Collie" />  Bearded Collie
			<option value = "Beauceron" />  Beauceron 
			<option value = "Bedington Terrier"/>  Bedington Terrier
			<option value = "Belgin Malinois"/> Belgin Malinois
			<option value = "Belgian Sheepdog"/>  Belgian Sheepdog
			<option value = "Belgian Tervuren"/>  Belgian Tervuren
			<option value = "Bernese Mountain Dog"/>  Bernese Mountain Dog
			<option value = "Bichon Frise"/>  Bichon Frise
			<option value = "Black and Tan Greyhound" />  Black and Tan Greyhound
			<option value = "Black Russian Terrier" />  Black Russian Terrier
			<option value = "Bloodhoung" />  Bloodhound
			<option value = "Border Collie" /> Border Collie
			<option value = "Border Terrier"/> Border Terrier
			<option value = "Borzoi"/>  Borzoi
			<option value = "Boston Terrier"/>  Boston Terrier
			<option value = "Bouvier des Flandres"/>  Bouvier des Flandres
			<option value = "Boxer"/>  Boxer
			<option value = "Briard"/>  Briard
			<option value = "Brittany" />  Brittany
			<option value = "Brussels Griffon" />  Brussels Griffon
			<option value = "Bulldog" /> Bulldog
			<option value = "Bullmastiff" /> Bullmasttiff
			<option value = "Bull Terrier" />  Bull Terrier
			<option value = "Cairn Terrier" />  Cairn Terrier
			<option value = "Canaan Dog" />  Canaan Dog
			<option value = "Cardigan Welsh Corgi" />  Cardigan Welsh Corgi
			<option value = "Cavalier King Charles Spaniel" />Cavalier King Charles   	                                 Spaniel
			<option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever
			<option value = "Chilauhua" /> Chilauhua
			<option value = "Chinese Created" />  Chinese Crested
			<option value = "Chinese Shar-Pei" />  Chinese Shar-Pei
			<option value = "Chow Chow" />  Chow Chow
			<option value = "Clumber Spaniel" />  Clumber Spaniel
			<option value = "Cocker Spaniel" />  Cocker Spaniel
			<option value = "Collie" />  Collie
			<option value = "Curly-Coated Retrieve" />  Curly-Coated Retriever
			<option value = "Dachshound" />  Dachshund
			<option value = "Dalmation" /> Dalmation
			<option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier
			<option value = "Doberman Pincher" />  Doberman Pincher
			<option value = "Dogue de Bordeaux" /> Dogue de Bordeaux
			<option value = "English Cocker Spaniel" />  English Cocker Spaniel  
			<option value = "English Foxhound" />  English Foxhound
			<option value = "English Setter" />  English Setter
			<option value = "English Springer" /> English Springer
			<option value = "English Toy Spaniel" />  English Toy Spaniel
			<option value = "Field Spaniel" /> Field Spaniel
			<option value = "Finnish Spitz" />  Finnish Spitz
			<option value = "Flat-Coated Retriever" />  Flat-Coated Retriever
			<option value = "French Bulldog" />  French Bulldog
			<option value = "German Shepherd Dog" /> German Shepherd Dog
			<option value = "German Shorthaired Pointer"/>German Shorthaired Pointer
			<option value = "German Wirehaired Pointer" />  German Wirehaired Pointer 
			<option value = "Giant Schnauzer" /> Giant Schnauzer
			<option value = "Glen of Imaal Terrier" />  Glen of Imaal Terrier
			<option value = "Golden Retriever" /> Golden Retriever
			<option value = "Gorden Setter" /> Gorden Setter
			<option value = "Great Dane" /> Great Dane
			<option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog
			<option value = "Great Pyrenees" /> Great Pyrenees
			<option value = "Greyhound" /> Greyhound
			<option value = "Harrier"  /> Harrier
			<option value = "Havanese" />  Havanese
			<option value = "Ibizen Hound" /> Ibizen Hound 
			<option value = "Irish Setter" />  Irish Setter
			<option value = "Irish Terrier" /> Irish Terrier
			<option value = "Irish Water Spaniel" /> Irish Water Spaniel
			<option value = "Irish Wolfhound" />  Irish Wolfhound
			<option value = "Italian Greyhound" />  Italian Greyhound
			<option value = "Jack Russell Terrier" />  Jack Russell Terrier
			<option value = "Japanese Chin" />  Japanese Chin
			<option value = "Keeshound" />  Keeshound
			<option value = "Kerry Blue TErrier" />  Kerry Blue Terrier
			<option value = "Komondor" /> Komondor
			<option value = "Kuvasz" />  Kuvasz
			<option value = "Labradar Retriever" />  Labrador Retriever
			<option value = "Lakeland Terrier" />  Lakeland Terrier
			<option value = "Lhasa Apso" />  Lhasa Apso
			<option value = "Lowchen" />  Lowchen
			<option value = "Maltese" />  Maltese
			<option value = "Standard Manchester Terrier" /> Standard Manchester Terrier
			<option value = "Mastiff" />  Mastiff
			<option value = "Miniature Bull Terrier" />  Miniature Bull Terrier
			<option value = "Miniature Pinche" /> Miniature Pinscher
			<option value = "Miniature Poodle" /> Miniature Poodle
			<option value = "Miniature Schnauzer" />Miniature Schnauzer
			<option value = "Mutt" />Mutt
			<option value = "Neopolitan Mastiff" />Neopolitan Mastiff
			<option value = "Newfoundland&nbsp" /> Newfoundland 
			<option value = "Newfolk Terrier" />Norfolk Terrier
			<option value = "Norwegian Elkhound" /> Norwegian Elkhound
			<option value = "Norwich Terrier" /> Norwich Terrier
			<option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck 	                                 Tolling Retriever
			<option value = "Old English Sheepdog" />Old English Sheepdog
			<option value = "Otterhound" /> Otterhound
			<option value = "Papillon" />Papillon
			<option value = "Parson Russell Terrier" /> Parson Russell Terrier
			<option value = "Pekingese" />Pekingese
			<option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi
			<option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen
			<option value = "Pharch Hound" />Pharoh Hound
			<option value = "Plott" /> Plott
			<option value = "Pointer" /> Pointer 
			<option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog
			<option value = "Pomeranian" /> Pomeranian
			<option value = "Portuguese Water Dog" />Portuguese Water Dog 
			<option value = "Pug" />Pug
			<option value = "Pull" />Puli
			<option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback
			<option value = "Rottweiler" />Rottweiler
			<option value = "ASaint Bernard" /> Saint Bernard
			<option value = "Saluki" /> Saluki
			<option value = "Samoyed" />Samoyed
			<option value = "Schipperke" />Schipperke
			<option value = "Scottish Doverhound" />Scottish Deerhound
			<option value = "Scottish Terrier" />Scottish Terrier
			<option value = "Sealyham Terrier" />Sealyham Terrier
			<option value = "Shetland Sheepdog" />Shetland Sheepdog
			<option value = "Shiba Inu" />Shiba Inu
			<option value = "Shih Tzu" />Shih Tzu
			<option value = "Siberian Husky" />Siberian Husky
			<option value = "Silky Terrier" />Silky Terrier
			<option value = "Skye Terrier" />Skye Terrier 
			<option value = "Smooth Fox Terrier" />Smooth Fox Terrier
			<option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier
			<option value = "Spinone Italiano" />Spinone Italiano
			<option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier
			<option value = "Standard Poodle" />Standard Poodle
			<option value = "Standard Schnauer" /> Standard Schnauzer
			<option value = "Suseex Spaniel"  />Sussex Spaniel
			<option value = "Swedish Vallhound" />Swedish Vallhund
			<option value = "Tibertan Mastiff" />Tibetan Mastiff
			<option value = "Tibertan Spaniel" />Tibetan Spaniel
			<option value = "Tibetan Terrier" />Tibetan Terrier 
			<option value = "Toy Fox Terrier" />Toy Fox Terrier 
			<option value = "Toy Manchester Terrier" />Toy Manchester Terrier 
                <option value = "Toy Poodle" />Toy Poodle
			<option value = "Vizela" />Vizela
			<option value = "Weimaraner" />Weimaraner
			<option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel
			<option value = "Welsh Terrier" />Welsh Terrier 
			<option value = "West Highland White Terrier" />West Highland White Terrier 
			<option value = "Whippet" />Whippet
			<option value = "Wire Fox Terrier" />Wire Fox Terrier 
			<option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon
			<option value = "Yorkshire Terrier" />Yorkshire Terrier 	

</td>
</select>
</tr>
<tr>
<td>Nutritional Needs:</td>
<td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Special Instructions</td>
<td><textarea name="specialInstructions" cols="17" rows="5"></textarea>
</tr>
<tr>
<td colspan = "6"><h2>Order Information</h2></td>
</tr>
<tr>
HEREDOC;
foreach($key as $value){
	echo $value;
}
echo <<<HEREDOC
</tr>
<tr>
<td> <input name="Submit" type="button" value="Order Treats!" /></td><td><input name="reset" type="button" value="Cancel Order" /> </td>
</tr>
HEREDOC;
?>
</table>
</form> 
<div id = "footer">
Auntie Vic's Treatery <br />
PO Box 34092 <br />
Clermont, IN 46234<br />
317-701-0343 <br />
<a href="mailto:auntievics@gmail.com">Email Us</a>
</div>
</body>
</html>

This would be used at check out.  Make sure you have session_start(); at the top of the page.  Here I am just echoing the results.  Change as need for your application.

 

<?php
IF (isset($_SESSION['cart'])){
foreach ($_SESSION['cart'] as $key => $value){
echo "Product Number $key Quantity $value<br />";
}
}
?>

I tried it again and still nothing will transfer.  I'm needing the product name, price and quantity to transfer.  Could you explain echo "Product Number $key Quantity $value<br />";  Is that the quantity coming from the the treats page ?

 

<?php
session_start();
IF (isset($_SESSION['cart'])){
foreach ($_SESSION['cart'] as $key => $value){
echo "Product Number $key Quantity $value<br />";
}
}
require_once("functions.php");
DatabaseConnection(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ordering doggy treats</title>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#order {

margin-right: auto;
margin-left: auto;
}
.orderRow{
padding-bottom: 50px;
}
h2 {
text-align: center;
}

</style>
</head>
<body>
<?php
//error code 
navBar();
echo <<<HEREDOC
<div id="logo"><img src="assets/logo.gif" width="182" height="123" alt="logo" /></div>
<table id="order">  
<form action="checkOut.php" method="post" name="checkOut">

<caption><h2>Customer Information </h2> </caption>
<tr class = "orderRow">
<td> First Name:<br />
     <input name="fname" type="text" size="10" maxlength="20" />  		  
    </td>  
<td> Last Name: <br />
     <input name="lname" type="text" size="10" maxlength="20" /> 
</td>
<td>    Address: <br />
         <input name="address " type="text"  size="25" /> 
</td>  
</tr>
<tr class = "orderRow">
	<td>  City:  <br />
      <input name="city " type="text" size="15" maxlength="20" /> 
</td>
<td>   State:   <br />
          <select name = "state">  <option selected value ="Please choose a state"/>
		Please choose a state</option>
		<option value = "AL" />AL</option>
		<option value = "AK" />AK</option>
		<option value = "AR" />AR</option>
		<option value = "AZ" />AZ
		<option value = "CA" />CA
		<option value = "CO" />CO
		<option value = "CT" />CT
		<option value = "DE" />DE
		<option value = "DC" />DC
		<option value = "FL" />FL
		<option value = "GA" />GA
		<option value = "HI" />HI															
		<option value = "IA" />IA
		<option value = "ID" />ID
		<option value = "IL" />IL
		<option value = "IN" />IN
		<option value = "KS" />KS
		<option value = "KY" />KY
		<option value = "LA" />LA
		<option value = "MA" />MA
		<option value = "ME" />ME
		<option value = "MD" />MD
		<option value = "MI" />MI
		<option value = "MN" />MN
		<option value = "MO" />MO
		<option value = "MS" />MS
		<option value = "MT" />MT
		<option value = "NC" />NC
		<option value = "ND" />ND
		<option value = "NE" />NE
		<option value = "NH" />NH
		<option value = "NJ" />NJ
		<option value = "NM" />NM
		<option value = "OH" />OH
		<option value = "OK" />OK
		<option value = "OR" />OR
		<option value = "PA" />PA
		<option value = "RI" />RI
		<option value = "SC" />SC
		<option value = "SD" />SD
		<option value = "TN" />TN
		<option value = "TX" />TX
		<option value = "UT" />UT
		<option value = "VA" />VA
			<option value = "VT" />VT
		<option value = "WA" />WA
		<option value = "WI" />WI
		<option value = "WV" />WV
		<option value = "WY" />WY
		</select> 
  </td>   
<td>  Zip Code:<br />
          <input name="zipcode" type="text" size="5" maxlength="5" /> 
</td>  
</tr>  
<tr class = "orderRow">
<td> Phone  <br />  Please include area code <br />  
    <input name="phone" type="text" size="13" maxlength="13" /> 
</td>
<td>  Fax:<br />   
    <input name="" type="text" size="13" maxlength="13" /> 
    </td>
<td>   Email: <br />  
<input name="email " type="text" size="15" maxlength="30" />
</td>
</tr>
<tr class = "orderRow">  
     <td>   Please choose method of payment: <br /> 
Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td>
</tr>
<tr>
<td colspan = "6">	 <h2>  Pet Information </h2></td>
</tr>
<tr>
  <td>  Name: <br /> 
      <input name="petName" type="text" size="10" maxlength="20" /> 
  </td>  
<td>   Age: <br />
<select name="age">  
HEREDOC;
  for ($age =1; $age <=20; $age ++)
	{
	print "<option value=\"age\">  $age</option>"; 
}
echo <<<HEREDOC
</select>
</td>   
<td>   Breed:<br />
<select name = "breed">  <option selected value ="Please choose a breed"/>
		Please choose a breed
		    <option value = "I don't know" />I don't know 
			<option value = "Affernpincher" />Affernpincher
			<option value = "Afghan Hound" />Afghan Hound 
			<option value = "Airedale Terrier" /> Airedale Terrior
			<option value = "Akita" />  Akita 
			<option value = "Alaskan Malamute" />  Alaskan Malamute
			<option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog
			<option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo 		                                 Dog
			<option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog
			<option value = "American Foxhound" />  American Foxhound
			<option value = "American Staffordshire Terrier" />  American Staffordshhire                                 Terrier
			<option value = "American Water Spaniel" /> American Water Spaniel
			<option value = "Australian Shepherd Dog"/>  Anatolian Shepherd Dog 
			<option value = "Australian Cattle Dog"/>  Australian Cattle Dog
			<option value = "Australian Shepherd"/>  Australian Shepherd 
			<option value = "Australian Terrier" />  Australia Terrier
			<option value = "Basenji" />  Basenji
			<option value = "Basset Hound" />  Basset Hound 
			<option value = "Beagle" />  Beagle
			<option value = "Bearded Collie" />  Bearded Collie
			<option value = "Beauceron" />  Beauceron 
			<option value = "Bedington Terrier"/>  Bedington Terrier
			<option value = "Belgin Malinois"/> Belgin Malinois
			<option value = "Belgian Sheepdog"/>  Belgian Sheepdog
			<option value = "Belgian Tervuren"/>  Belgian Tervuren
			<option value = "Bernese Mountain Dog"/>  Bernese Mountain Dog
			<option value = "Bichon Frise"/>  Bichon Frise
			<option value = "Black and Tan Greyhound" />  Black and Tan Greyhound
			<option value = "Black Russian Terrier" />  Black Russian Terrier
			<option value = "Bloodhoung" />  Bloodhound
			<option value = "Border Collie" /> Border Collie
			<option value = "Border Terrier"/> Border Terrier
			<option value = "Borzoi"/>  Borzoi
			<option value = "Boston Terrier"/>  Boston Terrier
			<option value = "Bouvier des Flandres"/>  Bouvier des Flandres
			<option value = "Boxer"/>  Boxer
			<option value = "Briard"/>  Briard
			<option value = "Brittany" />  Brittany
			<option value = "Brussels Griffon" />  Brussels Griffon
			<option value = "Bulldog" /> Bulldog
			<option value = "Bullmastiff" /> Bullmasttiff
			<option value = "Bull Terrier" />  Bull Terrier
			<option value = "Cairn Terrier" />  Cairn Terrier
			<option value = "Canaan Dog" />  Canaan Dog
			<option value = "Cardigan Welsh Corgi" />  Cardigan Welsh Corgi
			<option value = "Cavalier King Charles Spaniel" />Cavalier King Charles   	                                 Spaniel
			<option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever
			<option value = "Chilauhua" /> Chilauhua
			<option value = "Chinese Created" />  Chinese Crested
			<option value = "Chinese Shar-Pei" />  Chinese Shar-Pei
			<option value = "Chow Chow" />  Chow Chow
			<option value = "Clumber Spaniel" />  Clumber Spaniel
			<option value = "Cocker Spaniel" />  Cocker Spaniel
			<option value = "Collie" />  Collie
			<option value = "Curly-Coated Retrieve" />  Curly-Coated Retriever
			<option value = "Dachshound" />  Dachshund
			<option value = "Dalmation" /> Dalmation
			<option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier
			<option value = "Doberman Pincher" />  Doberman Pincher
			<option value = "Dogue de Bordeaux" /> Dogue de Bordeaux
			<option value = "English Cocker Spaniel" />  English Cocker Spaniel  
			<option value = "English Foxhound" />  English Foxhound
			<option value = "English Setter" />  English Setter
			<option value = "English Springer" /> English Springer
			<option value = "English Toy Spaniel" />  English Toy Spaniel
			<option value = "Field Spaniel" /> Field Spaniel
			<option value = "Finnish Spitz" />  Finnish Spitz
			<option value = "Flat-Coated Retriever" />  Flat-Coated Retriever
			<option value = "French Bulldog" />  French Bulldog
			<option value = "German Shepherd Dog" /> German Shepherd Dog
			<option value = "German Shorthaired Pointer"/>German Shorthaired Pointer
			<option value = "German Wirehaired Pointer" />  German Wirehaired Pointer 
			<option value = "Giant Schnauzer" /> Giant Schnauzer
			<option value = "Glen of Imaal Terrier" />  Glen of Imaal Terrier
			<option value = "Golden Retriever" /> Golden Retriever
			<option value = "Gorden Setter" /> Gorden Setter
			<option value = "Great Dane" /> Great Dane
			<option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog
			<option value = "Great Pyrenees" /> Great Pyrenees
			<option value = "Greyhound" /> Greyhound
			<option value = "Harrier"  /> Harrier
			<option value = "Havanese" />  Havanese
			<option value = "Ibizen Hound" /> Ibizen Hound 
			<option value = "Irish Setter" />  Irish Setter
			<option value = "Irish Terrier" /> Irish Terrier
			<option value = "Irish Water Spaniel" /> Irish Water Spaniel
			<option value = "Irish Wolfhound" />  Irish Wolfhound
			<option value = "Italian Greyhound" />  Italian Greyhound
			<option value = "Jack Russell Terrier" />  Jack Russell Terrier
			<option value = "Japanese Chin" />  Japanese Chin
			<option value = "Keeshound" />  Keeshound
			<option value = "Kerry Blue TErrier" />  Kerry Blue Terrier
			<option value = "Komondor" /> Komondor
			<option value = "Kuvasz" />  Kuvasz
			<option value = "Labradar Retriever" />  Labrador Retriever
			<option value = "Lakeland Terrier" />  Lakeland Terrier
			<option value = "Lhasa Apso" />  Lhasa Apso
			<option value = "Lowchen" />  Lowchen
			<option value = "Maltese" />  Maltese
			<option value = "Standard Manchester Terrier" /> Standard Manchester Terrier
			<option value = "Mastiff" />  Mastiff
			<option value = "Miniature Bull Terrier" />  Miniature Bull Terrier
			<option value = "Miniature Pinche" /> Miniature Pinscher
			<option value = "Miniature Poodle" /> Miniature Poodle
			<option value = "Miniature Schnauzer" />Miniature Schnauzer
			<option value = "Mutt" />Mutt
			<option value = "Neopolitan Mastiff" />Neopolitan Mastiff
			<option value = "Newfoundland&nbsp" /> Newfoundland 
			<option value = "Newfolk Terrier" />Norfolk Terrier
			<option value = "Norwegian Elkhound" /> Norwegian Elkhound
			<option value = "Norwich Terrier" /> Norwich Terrier
			<option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck 	                                 Tolling Retriever
			<option value = "Old English Sheepdog" />Old English Sheepdog
			<option value = "Otterhound" /> Otterhound
			<option value = "Papillon" />Papillon
			<option value = "Parson Russell Terrier" /> Parson Russell Terrier
			<option value = "Pekingese" />Pekingese
			<option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi
			<option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen
			<option value = "Pharch Hound" />Pharoh Hound
			<option value = "Plott" /> Plott
			<option value = "Pointer" /> Pointer 
			<option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog
			<option value = "Pomeranian" /> Pomeranian
			<option value = "Portuguese Water Dog" />Portuguese Water Dog 
			<option value = "Pug" />Pug
			<option value = "Pull" />Puli
			<option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback
			<option value = "Rottweiler" />Rottweiler
			<option value = "ASaint Bernard" /> Saint Bernard
			<option value = "Saluki" /> Saluki
			<option value = "Samoyed" />Samoyed
			<option value = "Schipperke" />Schipperke
			<option value = "Scottish Doverhound" />Scottish Deerhound
			<option value = "Scottish Terrier" />Scottish Terrier
			<option value = "Sealyham Terrier" />Sealyham Terrier
			<option value = "Shetland Sheepdog" />Shetland Sheepdog
			<option value = "Shiba Inu" />Shiba Inu
			<option value = "Shih Tzu" />Shih Tzu
			<option value = "Siberian Husky" />Siberian Husky
			<option value = "Silky Terrier" />Silky Terrier
			<option value = "Skye Terrier" />Skye Terrier 
			<option value = "Smooth Fox Terrier" />Smooth Fox Terrier
			<option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier
			<option value = "Spinone Italiano" />Spinone Italiano
			<option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier
			<option value = "Standard Poodle" />Standard Poodle
			<option value = "Standard Schnauer" /> Standard Schnauzer
			<option value = "Suseex Spaniel"  />Sussex Spaniel
			<option value = "Swedish Vallhound" />Swedish Vallhund
			<option value = "Tibertan Mastiff" />Tibetan Mastiff
			<option value = "Tibertan Spaniel" />Tibetan Spaniel
			<option value = "Tibetan Terrier" />Tibetan Terrier 
			<option value = "Toy Fox Terrier" />Toy Fox Terrier 
			<option value = "Toy Manchester Terrier" />Toy Manchester Terrier 
                <option value = "Toy Poodle" />Toy Poodle
			<option value = "Vizela" />Vizela
			<option value = "Weimaraner" />Weimaraner
			<option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel
			<option value = "Welsh Terrier" />Welsh Terrier 
			<option value = "West Highland White Terrier" />West Highland White Terrier 
			<option value = "Whippet" />Whippet
			<option value = "Wire Fox Terrier" />Wire Fox Terrier 
			<option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon
			<option value = "Yorkshire Terrier" />Yorkshire Terrier 	

</td>
</select>
</tr>
<tr>
<td>Nutritional Needs:</td>
<td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Special Instructions</td>
<td><textarea name="specialInstructions" cols="17" rows="5"></textarea>
</tr>
<tr>
<td colspan = "6"><h2>Order Information</h2></td>
</tr>
<tr>
HEREDOC;
foreach($key as $value){
	echo $value;
}
echo <<<HEREDOC
</tr>
<tr>
<td> <input name="Submit" type="button" value="Order Treats!" /></td><td><input name="reset" type="button" value="Cancel Order" /> </td>
</tr>
</table>
</form> 
HEREDOC;
footer();
?>

</body>
</html>

This would be used at check out.  Make sure you have session_start(); at the top of the page.  Here I am just echoing the results.  Change as need for your application.

 

<?php
IF (isset($_SESSION['cart'])){
foreach ($_SESSION['cart'] as $key => $value){
echo "Product Number $key Quantity $value<br />";
}
}
?>

You are storing the product ID and the quantity ordered in your session (from treats).  I assume you have that working.  Within the foreach statement on the checkout page you will query the DB for product name and price and using the "$value" (which is the quantity ordered) calculate the total price.

I truly apologize.  I can grasp most PHP concepts, but this is one I'm not getting.  I think I understand about querying the database for the name and price, but I'm not understanding what you mean by $value.  Sorry about this  :-[

You are storing the product ID and the quantity ordered in your session (from treats).  I assume you have that working.  Within the foreach statement on the checkout page you will query the DB for product name and price and using the "$value" (which is the quantity ordered) calculate the total price.

OK.  On treats.php in the processing section you would add the header line like this.  Make sure the name matches your page name, i.e. checkOut.php.

<?php
require_once("functions.php"); 
IF (isset($_POST['submit'])){
$cart=array();
foreach ($_POST as $key => $value){
IF ($value!="Add to Cart" && !empty($value)){
$cart[$key] = $value;
}// IF ($value!="Add to Cart")
}// foreach ($_POST as $key => $value)
session_start();
$_SESSION['cart']=$cart;
header("Location:  checkOut.php");
}
?> 

Now your checkout page had a number of issues and you hadn't started any form processing so I made a version of this page for you.  Before incorporating into your application as far as modifying it, try it on it's own.  Add your DB info and look at comments at the top.  You will see it will create the database and tables used on this page.  I suggest you let it create a new DB so it doesn't mess with anything you've got going and then re-comment the "create tables" section.  I would then run your treats page to set some items to session.  Hopefully, your header will then direct you to this page.  The form/table had a number of issues, which I fixed and I added some processing and validation to it as well.  After filling out the form, you are shown a order confirmation and when clicked all values are processed and added to the different DB tables.  Hope this helps you get going.

<?php 
//Include your db connection info//
$host	= "localhost";
$login 	= "";
$pass 	= "";
//database name.  Change if desired//
$db 	= "doggietreats";
$link = mysql_connect($host,$login,$pass);
mysql_connect("$host","$login","$pass") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());

//The section below creates the database and adds the tables used in this example.  Remove the /* and */ tags around this section to create tables then remove.	  Note:  This section creates a table called `products`.  Remove if not needed.  Be sure the query `products` below matches table and fields you are using.

/*
$sql = "CREATE DATABASE $db";
if (mysql_query($sql, $link)) {
//    echo "Database $db created successfully\n";
} else {
    echo 'Error creating database: ' . mysql_error() . "\n";
}
mysql_select_db("$db") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());
/////
//Add product table for my version.  Don't use if you have table already!// 
///// 
mysql_query("CREATE TABLE IF NOT EXISTS products (
  `productname` varchar(35) NOT NULL,
  `description` text NOT NULL,
  `cost` varchar(5) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table products.  This script has stopped.");
//////
/////////////////////////Continue with other tables//////////////////////// 
///// 
mysql_query("CREATE TABLE IF NOT EXISTS customer (
  `fname` varchar(35) NOT NULL,
  `lname` varchar(35) NOT NULL,
  `address` varchar(35) NOT NULL,
  `email` varchar(20) NOT NULL,
  `phone` varchar(12) NOT NULL,
  `fax` varchar(12) NOT NULL,
  `country` varchar(30) NOT NULL,
  `state` varchar(30) NOT NULL,
  `city` varchar(30) NOT NULL,
  `zip` varchar(15) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table customer.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS pets (
  `petname` varchar(35) NOT NULL,
  `breed` varchar(35) NOT NULL,
  `nutritionalneeds` text NOT NULL,
  `specialinstructions` text NOT NULL,
  `orderid` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table pets.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS orders (
  `total` varchar(5) NOT NULL,
  `payments` varchar(5) NOT NULL,
  `adjustments` varchar(5) NOT NULL,
  `orderdate` varchar(10) NOT NULL,
  `paymentdate` varchar(10) NOT NULL,
  `customerid` int(11) NOT NULL,
  `orderid` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (orderid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table orders.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS orderdetails ( 
  `itemid` int(11) NOT NULL,
  `itemname` varchar(35) NOT NULL,
  `cost` varchar(5) NOT NULL,
  `quanitiy` int(5) NOT NULL,
  `subtotal` varchar(5) NOT NULL,
  `customerid` int(11) NOT NULL,
  `orderid` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table orderdetails.  This script has stopped.");
*/
//end create DB

//On my version I use this section to connect to db when DB creation section is blocked or removed.

mysql_select_db("$db") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());



/////////////////
///Start Page///
///////////////
session_start();
//require_once("functions.php");
//DatabaseConnection();
function getPostVar($varname)
{
     if(isset($_POST[$varname]))
    {
        return trim($_POST[$varname]);
    }
    return '';
}

$fname = getPostVar('fname');
$lname = getPostVar('lname');
$address = getPostVar('address');
$city = getPostVar('city');
$state = getPostVar('state');
$zipcode = getPostVar('zipcode');
$phone = getPostVar('phone');
$fax = getPostVar('fax');
$email = getPostVar('email');
$payment = getPostVar('payment');
$postage = getPostVar('age');
$breed = getPostVar('breed');
$petName = getPostVar('petName');
$nutritionalNeeds = getPostVar('nutritionalNeeds');
$specialInstructions = getPostVar('specialInstructions');
//Flag used for showing form and confirmation section//
$showconfirmation="f";
$thankyou="f";
//Start form processing
IF (isset($_POST['submit'])){
//*fname//
if(!empty($_POST['fname'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['fname'])){
$fn_bad='f';
}else{
$fn_bad='t';
$fn_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$fn_bad='t';
$fn_message="<span style=\"color:#ff0000\">Please add your first name</span>";
}
//*lname//
if(!empty($_POST['lname'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['lname'])){
$ln_bad='f';
}else{
$ln_bad='t';
$ln_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$ln_bad='t';
$ln_message="<span style=\"color:#ff0000\">Please add your last name</span>";
}
//*address// 
if(!empty($_POST['address'])){
$a_bad='f';
}else{
$a_bad='t';
$a_message="<span style=\"color:#ff0000\">Please add your Address</span>";
}
//*city// 
if(!empty($_POST['city'])){
$c_bad='f';
}else{
$c_bad='t';
$c_message="<span style=\"color:#ff0000\">Please add your city</span>";
}
//*state// 
if($_POST['state']!="Please choose a state"){
$s_bad='f';
}else{
$s_bad='t';
$s_message="<span style=\"color:#ff0000\">Please select your state</span>";
}
//*zipcode// 
if(!empty($_POST['zipcode']) && is_numeric($_POST['zipcode'])){
$z_bad='f';
}else{
if(empty($_POST['zipcode'])){
$z_bad='t';
$z_message="<span style=\"color:#ff0000\">Please add your zipcode</span>";
}
else{
$z_message="<span style=\"color:#ff0000\">Please enter a valid zipcode</span>";
}
}
//*phone// 
if(!empty($_POST['phone']) AND (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $_POST['phone']))){
$p_bad='f';
}else{
$p_bad='t';
$p_message="<span style=\"color:#ff0000\">Please add your telephone</span>";
}
//*fax// 
$f_bad='f';
if(!empty($_POST['fax'])){  
if (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $_POST['fax'])){
$f_bad='f';
}else{
$f_bad='t';
$f_message="<span style=\"color:#ff0000\">Please enter as 123-123-1234</span>";
}
}//if(!empty($_POST['fax']))
//*email// 
if(!empty($_POST['email'])){ 
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$e_bad='f';
}else{
$e_bad='t';
$e_message="<span style=\"color:#ff0000\">E-mail is not valid</span>";
}
}else{
$e_bad='t';
$e_message="<span style=\"color:#ff0000\">Please enter an Email Address</span>";
}
//*payment//
IF (isset($_POST['payment'])){
$pay_bad='f';
}else{
$pay_bad='t';
$pay_message="<span style=\"color:#ff0000\">Please select payment type</span>";
}
//*petname//
if(!empty($_POST['petName'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['petName'])){
$pn_bad='f';
}else{
$pn_bad='t';
$pn_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$pn_bad='t';
$pn_message="<span style=\"color:#ff0000\">Please add your pets name</span>";
}
//*breed// 
if($_POST['breed']!="Please choose a breed"){
$b_bad='f';
}else{
$b_bad='t';
$b_message="<span style=\"color:#ff0000\">Please select your pets breed</span>";
}

//Here we look at all flag variables and trigger order confirmation section
IF ($fn_bad=='f' && $ln_bad=='f' && $a_bad=='f' && $c_bad=='f' && $s_bad=='f' && $z_bad=='f' && $p_bad=='f' && $f_bad=='f' && $e_bad=='f' && $pay_bad=='f' && $pn_bad=='f' && $b_bad=='f'){
$showconfirmation="t";
//Here we look for order confirmation and continue if found//
IF (isset($_POST['mode']) && $_POST['mode']=="Confirm"){
//Here we go...///
$fname=mysql_real_escape_string($_POST['fname']);
$lname=mysql_real_escape_string($_POST['lname']);
$address=mysql_real_escape_string($_POST['address']);
$city=mysql_real_escape_string($_POST['city']);	
$state=mysql_real_escape_string($_POST['state']);
$zip=mysql_real_escape_string($_POST['zipcode']);
$phone=mysql_real_escape_string($_POST['phone']);
$fax=mysql_real_escape_string($_POST['fax']);
$email=mysql_real_escape_string($_POST['email']);
$pay=mysql_real_escape_string($_POST['payment']);
$petname=mysql_real_escape_string($_POST['petName']);
$age=mysql_real_escape_string($_POST['age']); 
$breed=mysql_real_escape_string($_POST['breed']);
$nutritionalNeeds=mysql_real_escape_string($_POST['nutritionalNeeds']);
$specialinstructions=mysql_real_escape_string($_POST['specialInstructions']);
$total=mysql_real_escape_string($_POST['total']);

//Add customer info
mysql_query("INSERT INTO `customer` (`fname`, `lname`, `address`, `email`, `phone`, `fax`, `country`, `state`, `city`, `zip`) VALUES
('$fname', '$lname', '$address', '$email', '$phone', '$fax', 'USA', '$state', '$city', '$zip')");

//Get customer id
$getid = mysql_query("SELECT id FROM customer ORDER BY id DESC limit 1");
WHILE($gtid = mysql_fetch_array($getid)) {
$custid=$gtid['id'];
}//$getid

//Add general order info
$date=date('Y-m-d');
mysql_query("INSERT INTO `orders` (`total`, `orderdate`, `customerid`) VALUES
('$total', '$date', '$custid')");

//Get order id
$getoid = mysql_query("SELECT orderid FROM orders ORDER BY orderid DESC limit 1");
WHILE($gtoid = mysql_fetch_array($getoid)) {
$orderid=$gtoid['orderid'];
}//$getoid 

//Add pet info for this order
mysql_query("INSERT INTO `pets` (`petname`, `breed`, `nutritionalneeds`, `specialinstructions`, `orderid`) VALUES
('$petname', '$breed', '$nutritionalNeeds', '$specialinstructions', '$orderid')");
//Add order details	
$_SESSION['subtotal']=0;
foreach ($_SESSION['cart'] as $key => $value){
$listproducts = mysql_query("SELECT productname,cost FROM products WHERE id=$key");
WHILE($lstprod = mysql_fetch_array($listproducts)) {
$itemname=$lstprod['productname'];
$procost=$lstprod['cost'];
//get subtotals
$subtotal=$procost*$value;
mysql_query("INSERT INTO `orderdetails` (`itemid`, `itemname`, `cost`, `quanitiy`, `subtotal`, `customerid`, `orderid`) VALUES
('$key', '$itemname', '$procost', '$value', '$subtotal', '$custid', '$orderid')");
}//$listproducts
}//foreach ($_SESSION['cart'] as $key => $value)
$thankyou="t";
}//IF (isset($_POST['mode'])
}//End if flag variables are good

}// END IF ($_POST['submit']=="Order Treats!")
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ordering doggy treats</title>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#order {

margin-right: auto;
margin-left: auto;
}
.orderRow{
padding-bottom: 50px;
}
h2 {
text-align: center;
}

</style>
</head>
<body>
<?php
//error code 
//navBar();
//echo <<<HEREDOC	
//Personally I would use an include statement as in include(navBar.php); for getting parts of the layout.
//print_r($_POST);
?>
<div id="logo"><img src="assets/logo.gif" width="182" height="123" alt="logo" /></div>  
<form action="checkOut.php" method="post" name="checkOut">
<?PHP
IF (($showconfirmation=="t" && $thankyou=="f") || $thankyou=="t"){
echo "<div style=\"display:none\">";
}
?>
<h2>Customer Information </h2> 
<table id="order" cellspacing=3>

<tr class = "orderRow">
<td width="33%"><?PHP if(isset($fn_message)){ echo "$fn_message<br />";} ?><span style="color:#ff0000">*</span>First Name:<br />
     <input name="fname" type="text" style="width:90%" value="<?PHP echo "$fname"; ?>" />  		  
    </td>  
<td width="33%"><?PHP if(isset($ln_message)){ echo "$ln_message<br />";} ?><span style="color:#ff0000">*</span>Last Name: <br />
     <input name="lname" type="text" style="width:90%" value="<?PHP echo "$lname"; ?>" /> 
</td>
<td width="33%"><?PHP if(isset($a_message)){ echo "$a_message<br />";} ?><span style="color:#ff0000">*</span>Address: <br />
         <input name="address" type="text" style="width:90%" value="<?PHP echo "$address"; ?>" /> 
</td>  
</tr>
<tr class = "orderRow">
	<td><?PHP if(isset($c_message)){ echo "$c_message<br />";} ?><span style="color:#ff0000">*</span>City:  <br />
      <input name="city" type="text" style="width:90%" value="<?PHP echo "$city"; ?>" /> 
</td>
<td><?PHP if(isset($s_message)){ echo "$s_message<br />";} ?><span style="color:#ff0000">*</span>State:   <br />
          <select name="state" style="width:92%">
	  <?PHP
	  IF (isset($_POST['state'])){echo "<option value = \"$state\">$state</option>"; }?>  
<option value="Please choose a state">Please choose a state</option>
		<option value = "AL">AL</option>
		<option value = "AK">AK</option>
		<option value = "AR">AR</option>
		<option value = "AZ">AZ</option>
		<option value = "CA">CA</option>
		<option value = "CO">CO</option>
		<option value = "CT">CT</option>
		<option value = "DE">DE</option>
		<option value = "DC">DC</option>
		<option value = "FL">FL</option>
		<option value = "GA">GA</option>
		<option value = "HI">HI</option>															
		<option value = "IA">IA</option>
		<option value = "ID">ID</option>
		<option value = "IL">IL</option>
		<option value = "IN">IN</option>
		<option value = "KS">KS</option>
		<option value = "KY">KY</option>
		<option value = "LA">LA</option>
		<option value = "MA">MA</option>
		<option value = "ME">ME</option>
		<option value = "MD">MD</option>
		<option value = "MI">MI</option>
		<option value = "MN">MN</option>
		<option value = "MO">MO</option>
		<option value = "MS">MS</option>
		<option value = "MT">MT</option>
		<option value = "NC">NC</option>
		<option value = "ND">ND</option>
		<option value = "NE">NE</option>
		<option value = "NH">NH</option>
		<option value = "NJ">NJ</option>
		<option value = "NM">NM</option>
		<option value = "OH">OH</option>
		<option value = "OK">OK</option>
		<option value = "OR">OR</option>
		<option value = "PA">PA</option>
		<option value = "RI">RI</option>
		<option value = "SC">SC</option>
		<option value = "SD">SD</option>
		<option value = "TN">TN</option>
		<option value = "TX">TX</option>
		<option value = "UT">UT</option>
		<option value = "VA">VA</option>
			<option value = "VT">VT</option>
		<option value = "WA">WA</option>
		<option value = "WI">WI</option>
		<option value = "WV">WV</option>
		<option value = "WY">WY</option>
		</select> 
  </td>   
<td><?PHP if(isset($z_message)){ echo "$z_message<br />";} ?><span style="color:#ff0000">*</span>Zip Code:<br />
          <input name="zipcode" type="text" style="width:90%" value="<?PHP echo "$zipcode"; ?>" /> 
</td>  
</tr>  
<tr class = "orderRow">
<td><?PHP if(isset($p_message)){ echo "$p_message<br />";} ?><span style="color:#ff0000">*</span>Phone ex: 123-623-6235<br />  
    <input name="phone" type="text" style="width:90%" value="<?PHP echo "$phone"; ?>" /> 
</td>
<td><?PHP if(isset($f_message)){ echo "$f_message<br />";} ?>  Fax:<br />   
    <input name="fax" type="text" style="width:90%" value="<?PHP echo "$fax"; ?>" /> 
    </td>
<td><?PHP if(isset($e_message)){ echo "$e_message<br />";} ?><span style="color:#ff0000">*</span>Email: <br />  
<input name="email" type="text" style="width:90%" value="<?PHP echo "$email"; ?>" />
</td>
</tr>
<tr class="orderRow">  
     <td colspan="3" align="center"><?PHP if(isset($pay_message)){ echo "$pay_message<br />";} ?><span style="color:#ff0000">*</span>Please choose method of payment: <br /> 
Check 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Check"){
echo "<input name=\"payment\" type=\"radio\" value=\"Check\" checked=\"checked\" />"; 
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Check\" />"; 
}
?>
   Money Order 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Money order"){
echo "<input name=\"payment\" type=\"radio\" value=\"Money order\" checked=\"checked\" />";
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Money order\" />";
}
?>
   PayPal 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Paypal"){
echo "<input name=\"payment\" type=\"radio\" value=\"Paypal\" checked=\"checked\" />";
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Paypal\" />";
}
?>
</td>
</tr>
<tr>
<td colspan="3" align="center">	 <h2>  Pet Information </h2></td>
</tr>
<tr>
  <td><?PHP if(isset($pn_message)){ echo "$pn_message<br />";} ?><span style="color:#ff0000">*</span>Name: <br /> 
      <input name="petName" type="text" style="width:90%" value="<?PHP echo "$petName"; ?>" /> 
  </td>  
<td align="center"><span style="color:#ff0000">*</span>Age: <br />
<select name="age" style="width:20%">  
<?PHP
IF (isset($_POST['age'])){
echo "<option value=\"$postage\">$postage</option>";
}
$age=1;
  while($age <=20)
	{
	print "<option value=\"$age\">  $age</option>";
  $age ++; 
}
?>
</select>
</td>   
<td><?PHP if(isset($b_message)){ echo "$b_message<br />";} ?><span style="color:#ff0000">*</span>Breed:<br />
<select name = "breed">  
<?PHP
IF (isset($_POST['breed'])){
echo "<option value=\"$breed\">$breed</option>";
}
ELSE{  
echo "<option selected value =\"Please choose a breed\">Please choose a breed</option>"; 
}
?>
<option value = "I don't know">I don't know</option> 
<option value = "Affernpincher">Affernpincher</option>
<option value = "Afghan Hound">Afghan Hound</option> 
<option value = "Airedale Terrier">Airedale Terrior</option>
<option value = "Akita">Akita</option> 
<option value = "Alaskan Malamute">Alaskan Malamute</option>
<option value = "Standard American Eskimo Dog">Standard American Eskimo Dog</option>
<option value = "Miniature American Eskimo Dog">Miniature American Eskimo Dog</option>
<option value = "Toy American Eskimo Dog">Toy American Eskimo Dog</option>
<option value = "American Foxhound">American Foxhound</option>
<option value = "American Staffordshire Terrier">American Staffordshhire Terrier</option>
<option value = "American Water Spaniel">American Water Spaniel</option>
<option value = "Australian Shepherd Dog">Anatolian Shepherd Dog</option> 
<option value = "Australian Cattle Dog">Australian Cattle Dog</option>
<option value = "Australian Shepherd">Australian Shepherd</option> 
<option value = "Australian Terrier">Australia Terrier</option>
<option value = "Basenji">Basenji</option>
<option value = "Basset Hound">Basset Hound</option> 
<option value = "Beagle">Beagle</option>
<option value = "Bearded Collie">Bearded Collie</option>
<option value = "Beauceron">Beauceron</option> 
<option value = "Bedington Terrier">Bedington Terrier</option>
<option value = "Belgin Malinois">Belgin Malinois</option>
<option value = "Belgian Sheepdog">Belgian Sheepdog</option>
<option value = "Belgian Tervuren">Belgian Tervuren</option>
<option value = "Bernese Mountain Dog">Bernese Mountain Dog</option>
<option value = "Bichon Frise">Bichon Frise</option>
<option value = "Black and Tan Greyhound">Black and Tan Greyhound</option>
<option value = "Black Russian Terrier">Black Russian Terrier</option>
<option value = "Bloodhoung">Bloodhound</option>
<option value = "Border Collie">Border Collie</option>
<option value = "Border Terrier">Border Terrier</option>
<option value = "Borzoi">Borzoi</option>
<option value = "Boston Terrier">Boston Terrier</option>
<option value = "Bouvier des Flandres">Bouvier des Flandres</option>
<option value = "Boxer">Boxer</option>
<option value = "Briard">Briard</option>
<option value = "Brittany">Brittany</option>
<option value = "Brussels Griffon">Brussels Griffon</option>
<option value = "Bulldog">Bulldog</option>
<option value = "Bullmastiff">Bullmasttiff</option>
<option value = "Bull Terrier">Bull Terrier</option>
<option value = "Cairn Terrier">Cairn Terrier</option>
<option value = "Canaan Dog">Canaan Dog</option>
<option value = "Cardigan Welsh Corgi">Cardigan Welsh Corgi</option>
<option value = "Cavalier King Charles Spaniel">Cavalier King Charles Spaniel</option>
<option value = "Chesepeake Bay Retriever">Chesapeake Bay Retriever</option>
<option value = "Chilauhua">Chilauhua</option>
<option value = "Chinese Created">Chinese Crested</option>
<option value = "Chinese Shar-Pei">Chinese Shar-Pei</option>
<option value = "Chow Chow">Chow Chow</option>
<option value = "Clumber Spaniel">Clumber Spaniel</option>
<option value = "Cocker Spaniel">Cocker Spaniel</option>
<option value = "Collie">Collie</option>
<option value = "Curly-Coated Retrieve">Curly-Coated Retriever</option>
<option value = "Dachshound">Dachshund</option>
<option value = "Dalmation">Dalmation</option>
<option value = "Dandle Dimonnt">Dandie Dinmont Terrier</option>
<option value = "Doberman Pincher">Doberman Pincher</option>
<option value = "Dogue de Bordeaux">Dogue de Bordeaux</option>
<option value = "English Cocker Spaniel">English Cocker Spaniel</option>  
<option value = "English Foxhound">English Foxhound</option>
<option value = "English Setter">English Setter</option>
<option value = "English Springer">English Springer</option>
<option value = "English Toy Spaniel">English Toy Spaniel</option>
<option value = "Field Spaniel">Field Spaniel</option>
<option value = "Finnish Spitz">  Finnish Spitz</option>
<option value = "Flat-Coated Retriever">  Flat-Coated Retriever</option>
<option value = "French Bulldog">  French Bulldog</option>
<option value = "German Shepherd Dog"> German Shepherd Dog</option>
<option value = "German Shorthaired Pointer">German Shorthaired Pointer</option>
<option value = "German Wirehaired Pointer">German Wirehaired Pointer 
<option value = "Giant Schnauzer">Giant Schnauzer</option>
<option value = "Glen of Imaal Terrier">Glen of Imaal Terrier</option>
<option value = "Golden Retriever">Golden Retriever</option>
<option value = "Gorden Setter">Gorden Setter</option>
<option value = "Great Dane">Great Dane</option>
<option value = "Greater Swiss Mountain Dog">Greater Swiss Mountain Dog</option>
<option value = "Great Pyrenees">Great Pyrenees</option>
<option value = "Greyhound">Greyhound</option>
<option value = "Harrier">Harrier</option>
<option value = "Havanese">Havanese</option>
<option value = "Ibizen Hound">Ibizen Hound</option> 
<option value = "Irish Setter">Irish Setter</option>
<option value = "Irish Terrier">Irish Terrier</option>
<option value = "Irish Water Spaniel">Irish Water Spaniel</option>
<option value = "Irish Wolfhound">Irish Wolfhound</option>
<option value = "Italian Greyhound">Italian Greyhound</option>
<option value = "Jack Russell Terrier">Jack Russell Terrier</option>
<option value = "Japanese Chin">Japanese Chin</option>
<option value = "Keeshound">Keeshound</option>
<option value = "Kerry Blue TErrier">Kerry Blue Terrier</option>
<option value = "Komondor">Komondor</option>
<option value = "Kuvasz"> Kuvasz</option>
<option value = "Labradar Retriever">Labrador Retriever</option>
<option value = "Lakeland Terrier">Lakeland Terrier</option>
<option value = "Lhasa Apso">Lhasa Apso</option>
<option value = "Lowchen">Lowchen</option>
<option value = "Maltese">Maltese</option>
<option value = "Standard Manchester Terrier">Standard Manchester Terrier</option>
<option value = "Mastiff">Mastiff</option>
<option value = "Miniature Bull Terrier">Miniature Bull Terrier</option>
<option value = "Miniature Pinche">Miniature Pinscher</option>
<option value = "Miniature Poodle">Miniature Poodle</option>
<option value = "Miniature Schnauzer">Miniature Schnauzer</option>
<option value = "Mutt">Mutt</option>
<option value = "Neopolitan Mastiff">Neopolitan Mastiff</option>
<option value = "Newfoundland">Newfoundland</option> 
<option value = "Newfolk Terrier">Norfolk Terrier</option>
<option value = "Norwegian Elkhound">Norwegian Elkhound</option>
<option value = "Norwich Terrier">Norwich Terrier</option>
<option value = "Nova Scotia Duck Tolling Retriever">Nova Scotia Duck Tolling Retriever</option>
<option value = "Old English Sheepdog">Old English Sheepdog</option>
<option value = "Otterhound">Otterhound</option>
<option value = "Papillon">Papillon</option>
<option value = "Parson Russell Terrier">Parson Russell Terrier</option>
<option value = "Pekingese">Pekingese</option>
<option value = "Pembroke Welsh Corgi">Pembroke Welsh Corgi</option>
<option value = "Petit Basset Griffon Vendeen">Petit Basset Griffon Vendeen</option>
<option value = "Pharch Hound">Pharoh Hound</option>
<option value = "Plott">Plott</option>
<option value = "Pointer">Pointer</option>
<option value = "Polish Lowland Sheepdog">Polish Lowland sheepdog</option>
<option value = "Pomeranian"> Pomeranian</option>
<option value = "Portuguese Water Dog">Portuguese Water Dog</option> 
<option value = "Pug">Pug</option>
<option value = "Pull">Puli</option>
<option value = "Rhodesian Ridgeback">Rhodesian Ridgeback</option>
<option value = "Rottweiler">Rottweiler</option>
<option value = "ASaint Bernard">Saint Bernard</option>
<option value = "Saluki">Saluki</option>
<option value = "Samoyed">Samoyed</option>
<option value = "Schipperke">Schipperke</option>
<option value = "Scottish Doverhound">Scottish Deerhound</option>
<option value = "Scottish Terrier">Scottish Terrier</option>
<option value = "Sealyham Terrier">Sealyham Terrier</option>
<option value = "Shetland Sheepdog">Shetland Sheepdog</option>
<option value = "Shiba Inu">Shiba Inu</option>
<option value = "Shih Tzu">Shih Tzu</option>
<option value = "Siberian Husky">Siberian Husky</option>
<option value = "Silky Terrier">Silky Terrier</option>
<option value = "Skye Terrier">Skye Terrier</option> 
<option value = "Smooth Fox Terrier">Smooth Fox Terrier</option>
<option value = "Soft Coated Wheaten Terrier">Soft Coated wheaten Terrier</option>
<option value = "Spinone Italiano">Spinone Italiano</option>
<option value = "Staffordshire Bull Terrier">Staffordshire Bull Terrier</option>
<option value = "Standard Poodle">Standard Poodle</option>
<option value = "Standard Schnauer">Standard Schnauzer</option>
<option value = "Suseex Spaniel">Sussex Spaniel</option>
<option value = "Swedish Vallhound">Swedish Vallhund</option>
<option value = "Tibertan Mastiff">Tibetan Mastiff</option>
<option value = "Tibertan Spaniel">Tibetan Spaniel</option>
<option value = "Tibetan Terrier">Tibetan Terrier</option> 
<option value = "Toy Fox Terrier">Toy Fox Terrier</option> 
<option value = "Toy Manchester Terrier">Toy Manchester Terrier</option> 
<option value = "Toy Poodle">Toy Poodle</option>
<option value = "Vizela">Vizela</option>
<option value = "Weimaraner">Weimaraner</option>
<option value = "Welsh Springer Spaniel">Welsh Springer Spaniel</option>
<option value = "Welsh Terrier">Welsh Terrier</option> 
<option value = "West Highland White Terrier">West Highland White Terrier</option> 
<option value = "Whippet">Whippet</option>
<option value = "Wire Fox Terrier">Wire Fox Terrier</option> 
<option value = "Wirehaired Pointing Griffon">Wirehaired Pointing Griffon</option>
<option value = "Yorkshire Terrier">Yorkshire Terrier</option>
</select> 	

</td>
</tr>
<tr>
<td colspan="3" align="center"><b>Nutritional Needs:</b></td>
</tr>
<tr>
<td colspan="3" align="center"><textarea name="nutritionalNeeds" cols="17" rows="1" style="width:100%"><?PHP echo "$nutritionalNeeds"; ?></textarea></td>
</tr>
<tr>
<td colspan="3" align="center"><b>Special Instructions</b></td>
</tr>
<tr>
<td colspan="3" align="center"><textarea name="specialInstructions" cols="17" rows="1" style="width:100%"><?PHP echo "$specialInstructions"; ?></textarea></td>
</tr>
<tr>
<td colspan="3" align="center"><h2>Order Information</h2></td>
</tr>
<tr>
<td align="center"><input name="submit" type="submit" value="Order Treats!" /></td>
<td align="center"><span style="color:#ff0000">* Required Fields</span></td>
<td align="center"><input name="reset" type="submit" value="Cancel Order" /></td>
</tr>
</table>
<?PHP
IF (($showconfirmation=="t" && $thankyou=="f") || $thankyou=="t"){
echo "</div>";
}
IF ($showconfirmation=="t" && $thankyou=="f"){
//*****************************//
//Start order confirmation display
//*****************************//
//IF adding tax add here otherwise set to zero 0//
$tax=7.5; // ex: $tax=7.5;
//IF Adding shipping add here//
$shipping=3.5;  // ex: $shipping=3.5; as in $3.50
echo "<center>";
echo "<h2>Please Confirm your order</h2>";
echo "<table border=0 cellpadding=3 cellspacing=0>";
echo "<tr>";
echo "<td align=\"center\">";

IF (isset($_SESSION['cart'])){
//Add subtotal = 0 in case user refreshes page
$_SESSION['subtotal']=0;
foreach ($_SESSION['cart'] as $key => $value){
$listproducts = mysql_query("SELECT productname,cost FROM products WHERE id=$key");
WHILE($lstprod = mysql_fetch_array($listproducts)) {
$productname=$lstprod['productname'];
$productcost=$lstprod['cost'];
echo "<b>$productname</b> <br />Quantity ordered: $value<br />Cost each: $$productcost<br /><br />";
//get subtotals
$subtotal=$productcost*$value;

$_SESSION['subtotal']=($_SESSION['subtotal']+$subtotal);
}//$listproducts
}//foreach ($_SESSION['cart'] as $key => $value)
}//IF (isset($_SESSION['cart'])) </td>
echo "</tr>";
echo "<tr>";
echo "<td align=\"right\" style=\"border-top:1px solid;\">";
echo "Sub Total: $$_SESSION[subtotal]";
IF ($tax>0){
$TaxOnOrder=($_SESSION['subtotal']*$tax)/100;
$TaxOnOrder=number_format($TaxOnOrder, 2);
echo "<br />Tax: $$TaxOnOrder";  
}
IF ($shipping>0){
$shipping=number_format($shipping, 2); 				 
echo "<br />Shipping: $$shipping";  
}  
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"right\" style=\"border-top:1px solid;\">";
//Change depending or if using tax and shipping
IF ($tax>0 && $shipping>0){
$total=$_SESSION['subtotal']+$TaxOnOrder+$shipping;
}
IF ($tax==0 && $shipping>0){
$total=$_SESSION['subtotal']+$shipping;
}
IF ($tax>0 && $shipping==0){
$total=$_SESSION['subtotal']+$TaxOnOrder;
}
IF ($tax==0 && $shipping==0){
$total=$_SESSION['subtotal'];
}
echo "TOTAL: $$total";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\">";
echo "<input name=\"total\" type=\"hidden\" value=\"$total\" />";
echo "<input name=\"mode\" type=\"hidden\" value=\"Confirm\" />";
echo "<input name=\"submit\" type=\"submit\" value=\"Confirm Order\" />";
echo "</td>";
echo "</tr>";


echo "</table>";
echo "</center>";

}// end IF ($showconfirmation=="t")
IF ($thankyou=="t"){
echo "<h2>Thank you for your order!</h2>";
}
?>
</form> 
</body>
</html>

Looks like I missed the payment type on the DB orders table and processing section, otherwise working great.

<?php 
//Include your db connection info//
$host	=  "localhost";
$login 	= "" ;
$pass 	= "";
//database name.  Change if desired//
$db 	= "doggietreats";
$link = mysql_connect($host,$login,$pass);
mysql_connect("$host","$login","$pass") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());

//The section below creates the database and adds the tables used in this example.  Remove the /* and */ tags around this section to create tables then remove.	  Note:  This section creates a table called `products`.  Remove if not needed.  Be sure the query `products` below matches table and fields you are using.

/*
$sql = "CREATE DATABASE $db";
if (mysql_query($sql, $link)) {
//    echo "Database $db created successfully\n";
} else {
    echo 'Error creating database: ' . mysql_error() . "\n";
}
mysql_select_db("$db") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());
/////
//Add product table for my version.  Don't use if you have table already!// 
///// 
mysql_query("CREATE TABLE IF NOT EXISTS products (
  `productname` varchar(35) NOT NULL,
  `description` text NOT NULL,
  `cost` varchar(5) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table products.  This script has stopped.");
//////
/////////////////////////Continue with other tables//////////////////////// 
///// 
mysql_query("CREATE TABLE IF NOT EXISTS customer (
  `fname` varchar(35) NOT NULL,
  `lname` varchar(35) NOT NULL,
  `address` varchar(35) NOT NULL,
  `email` varchar(20) NOT NULL,
  `phone` varchar(12) NOT NULL,
  `fax` varchar(12) NOT NULL,
  `country` varchar(30) NOT NULL,
  `state` varchar(30) NOT NULL,
  `city` varchar(30) NOT NULL,
  `zip` varchar(15) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table customer.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS pets (
  `petname` varchar(35) NOT NULL,
  `breed` varchar(35) NOT NULL,
  `nutritionalneeds` text NOT NULL,
  `specialinstructions` text NOT NULL,
  `orderid` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table pets.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS orders (
  `total` varchar(5) NOT NULL,
  `payments` varchar(5) NOT NULL,
  `adjustments` varchar(5) NOT NULL,
  `paymenttype` varchar(12) NOT NULL,
  `orderdate` varchar(10) NOT NULL,
  `paymentdate` varchar(10) NOT NULL,
  `customerid` int(11) NOT NULL,
  `orderid` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (orderid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table orders.  This script has stopped.");

mysql_query("CREATE TABLE IF NOT EXISTS orderdetails ( 
  `itemid` int(11) NOT NULL,
  `itemname` varchar(35) NOT NULL,
  `cost` varchar(5) NOT NULL,
  `quanitiy` int(5) NOT NULL,
  `subtotal` varchar(5) NOT NULL,
  `customerid` int(11) NOT NULL,
  `orderid` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ")OR DIE
("There is a problem with creating table orderdetails.  This script has stopped.");
*/
//end create DB

//On my version I use this section to connect to db when DB creation section is blocked or removed.

mysql_select_db("$db") OR DIE
        ("There is a problem with the system.  Please notify your system administrator." .mysql_error());



/////////////////
///Start Page///
///////////////
session_start();
//require_once("functions.php");
//DatabaseConnection();
function getPostVar($varname)
{
     if(isset($_POST[$varname]))
    {
        return trim($_POST[$varname]);
    }
    return '';
}

$fname = getPostVar('fname');
$lname = getPostVar('lname');
$address = getPostVar('address');
$city = getPostVar('city');
$state = getPostVar('state');
$zipcode = getPostVar('zipcode');
$phone = getPostVar('phone');
$fax = getPostVar('fax');
$email = getPostVar('email');
$payment = getPostVar('payment');
$postage = getPostVar('age');
$breed = getPostVar('breed');
$petName = getPostVar('petName');
$nutritionalNeeds = getPostVar('nutritionalNeeds');
$specialInstructions = getPostVar('specialInstructions');
//Flag used for showing form and confirmation section//
$showconfirmation="f";
$thankyou="f";
//Start form processing
IF (isset($_POST['submit'])){
//*fname//
if(!empty($_POST['fname'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['fname'])){
$fn_bad='f';
}else{
$fn_bad='t';
$fn_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$fn_bad='t';
$fn_message="<span style=\"color:#ff0000\">Please add your first name</span>";
}
//*lname//
if(!empty($_POST['lname'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['lname'])){
$ln_bad='f';
}else{
$ln_bad='t';
$ln_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$ln_bad='t';
$ln_message="<span style=\"color:#ff0000\">Please add your last name</span>";
}
//*address// 
if(!empty($_POST['address'])){
$a_bad='f';
}else{
$a_bad='t';
$a_message="<span style=\"color:#ff0000\">Please add your Address</span>";
}
//*city// 
if(!empty($_POST['city'])){
$c_bad='f';
}else{
$c_bad='t';
$c_message="<span style=\"color:#ff0000\">Please add your city</span>";
}
//*state// 
if($_POST['state']!="Please choose a state"){
$s_bad='f';
}else{
$s_bad='t';
$s_message="<span style=\"color:#ff0000\">Please select your state</span>";
}
//*zipcode// 
if(!empty($_POST['zipcode']) && is_numeric($_POST['zipcode'])){
$z_bad='f';
}else{
if(empty($_POST['zipcode'])){
$z_bad='t';
$z_message="<span style=\"color:#ff0000\">Please add your zipcode</span>";
}
else{
$z_message="<span style=\"color:#ff0000\">Please enter a valid zipcode</span>";
}
}
//*phone// 
if(!empty($_POST['phone']) AND (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $_POST['phone']))){
$p_bad='f';
}else{
$p_bad='t';
$p_message="<span style=\"color:#ff0000\">Please add your telephone</span>";
}
//*fax// 
$f_bad='f';
if(!empty($_POST['fax'])){  
if (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $_POST['fax'])){
$f_bad='f';
}else{
$f_bad='t';
$f_message="<span style=\"color:#ff0000\">Please enter as 123-123-1234</span>";
}
}//if(!empty($_POST['fax']))
//*email// 
if(!empty($_POST['email'])){ 
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$e_bad='f';
}else{
$e_bad='t';
$e_message="<span style=\"color:#ff0000\">E-mail is not valid</span>";
}
}else{
$e_bad='t';
$e_message="<span style=\"color:#ff0000\">Please enter an Email Address</span>";
}
//*payment//
IF (isset($_POST['payment'])){
$pay_bad='f';
}else{
$pay_bad='t';
$pay_message="<span style=\"color:#ff0000\">Please select payment type</span>";
}
//*petname//
if(!empty($_POST['petName'])){
if (preg_match('/([a-zA-Z]{2,20})/', $_POST['petName'])){
$pn_bad='f';
}else{
$pn_bad='t';
$pn_message="<span style=\"color:#ff0000\">Two letters or more required</span>";
}
}else{
$pn_bad='t';
$pn_message="<span style=\"color:#ff0000\">Please add your pets name</span>";
}
//*breed// 
if($_POST['breed']!="Please choose a breed"){
$b_bad='f';
}else{
$b_bad='t';
$b_message="<span style=\"color:#ff0000\">Please select your pets breed</span>";
}

//Here we look at all flag variables and trigger order confirmation section
IF ($fn_bad=='f' && $ln_bad=='f' && $a_bad=='f' && $c_bad=='f' && $s_bad=='f' && $z_bad=='f' && $p_bad=='f' && $f_bad=='f' && $e_bad=='f' && $pay_bad=='f' && $pn_bad=='f' && $b_bad=='f'){
$showconfirmation="t";
//Here we look for order confirmation and continue if found//
IF (isset($_POST['mode']) && $_POST['mode']=="Confirm"){
//Here we go...///
$fname=mysql_real_escape_string($_POST['fname']);
$lname=mysql_real_escape_string($_POST['lname']);
$address=mysql_real_escape_string($_POST['address']);
$city=mysql_real_escape_string($_POST['city']);	
$state=mysql_real_escape_string($_POST['state']);
$zip=mysql_real_escape_string($_POST['zipcode']);
$phone=mysql_real_escape_string($_POST['phone']);
$fax=mysql_real_escape_string($_POST['fax']);
$email=mysql_real_escape_string($_POST['email']);
$pay=mysql_real_escape_string($_POST['payment']);
$petname=mysql_real_escape_string($_POST['petName']);
$age=mysql_real_escape_string($_POST['age']); 
$breed=mysql_real_escape_string($_POST['breed']);
$nutritionalNeeds=mysql_real_escape_string($_POST['nutritionalNeeds']);
$specialinstructions=mysql_real_escape_string($_POST['specialInstructions']);
$total=mysql_real_escape_string($_POST['total']);

//Add customer info
mysql_query("INSERT INTO `customer` (`fname`, `lname`, `address`, `email`, `phone`, `fax`, `country`, `state`, `city`, `zip`) VALUES
('$fname', '$lname', '$address', '$email', '$phone', '$fax', 'USA', '$state', '$city', '$zip')");

//Get customer id
$getid = mysql_query("SELECT id FROM customer ORDER BY id DESC limit 1");
WHILE($gtid = mysql_fetch_array($getid)) {
$custid=$gtid['id'];
}//$getid

//Add general order info
$date=date('Y-m-d');
mysql_query("INSERT INTO `orders` (`total`, `paymenttype`, `orderdate`, `customerid`) VALUES
('$total', '$pay', '$date', '$custid')");

//Get order id
$getoid = mysql_query("SELECT orderid FROM orders ORDER BY orderid DESC limit 1");
WHILE($gtoid = mysql_fetch_array($getoid)) {
$orderid=$gtoid['orderid'];
}//$getoid 

//Add pet info for this order
mysql_query("INSERT INTO `pets` (`petname`, `breed`, `nutritionalneeds`, `specialinstructions`, `orderid`) VALUES
('$petname', '$breed', '$nutritionalNeeds', '$specialinstructions', '$orderid')");
//Add order details	
$_SESSION['subtotal']=0;
foreach ($_SESSION['cart'] as $key => $value){
$listproducts = mysql_query("SELECT productname,cost FROM products WHERE id=$key");
WHILE($lstprod = mysql_fetch_array($listproducts)) {
$itemname=$lstprod['productname'];
$procost=$lstprod['cost'];
//get subtotals
$subtotal=$procost*$value;
mysql_query("INSERT INTO `orderdetails` (`itemid`, `itemname`, `cost`, `quanitiy`, `subtotal`, `customerid`, `orderid`) VALUES
('$key', '$itemname', '$procost', '$value', '$subtotal', '$custid', '$orderid')");
}//$listproducts
}//foreach ($_SESSION['cart'] as $key => $value)
$thankyou="t";
}//IF (isset($_POST['mode'])
}//End if flag variables are good

}// END IF ($_POST['submit']=="Order Treats!")
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ordering doggy treats</title>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#order {

margin-right: auto;
margin-left: auto;
}
.orderRow{
padding-bottom: 50px;
}
h2 {
text-align: center;
}

</style>
</head>
<body>
<?php
//error code 
//navBar();
//echo <<<HEREDOC	
//Personally I would use an include statement as in include(navBar.php); for getting parts of the layout.
//print_r($_POST);
?>
<div id="logo"><img src="assets/logo.gif" width="182" height="123" alt="logo" /></div>  
<form action="checkOut.php" method="post" name="checkOut">
<?PHP
IF (($showconfirmation=="t" && $thankyou=="f") || $thankyou=="t"){
echo "<div style=\"display:none\">";
}
?>
<h2>Customer Information </h2> 
<table id="order" cellspacing=3>

<tr class = "orderRow">
<td width="33%"><?PHP if(isset($fn_message)){ echo "$fn_message<br />";} ?><span style="color:#ff0000">*</span>First Name:<br />
     <input name="fname" type="text" style="width:90%" value="<?PHP echo "$fname"; ?>" />  		  
    </td>  
<td width="33%"><?PHP if(isset($ln_message)){ echo "$ln_message<br />";} ?><span style="color:#ff0000">*</span>Last Name: <br />
     <input name="lname" type="text" style="width:90%" value="<?PHP echo "$lname"; ?>" /> 
</td>
<td width="33%"><?PHP if(isset($a_message)){ echo "$a_message<br />";} ?><span style="color:#ff0000">*</span>Address: <br />
         <input name="address" type="text" style="width:90%" value="<?PHP echo "$address"; ?>" /> 
</td>  
</tr>
<tr class = "orderRow">
	<td><?PHP if(isset($c_message)){ echo "$c_message<br />";} ?><span style="color:#ff0000">*</span>City:  <br />
      <input name="city" type="text" style="width:90%" value="<?PHP echo "$city"; ?>" /> 
</td>
<td><?PHP if(isset($s_message)){ echo "$s_message<br />";} ?><span style="color:#ff0000">*</span>State:   <br />
          <select name="state" style="width:92%">
	  <?PHP
	  IF (isset($_POST['state'])){echo "<option value = \"$state\">$state</option>"; }?>  
<option value="Please choose a state">Please choose a state</option>
		<option value = "AL">AL</option>
		<option value = "AK">AK</option>
		<option value = "AR">AR</option>
		<option value = "AZ">AZ</option>
		<option value = "CA">CA</option>
		<option value = "CO">CO</option>
		<option value = "CT">CT</option>
		<option value = "DE">DE</option>
		<option value = "DC">DC</option>
		<option value = "FL">FL</option>
		<option value = "GA">GA</option>
		<option value = "HI">HI</option>															
		<option value = "IA">IA</option>
		<option value = "ID">ID</option>
		<option value = "IL">IL</option>
		<option value = "IN">IN</option>
		<option value = "KS">KS</option>
		<option value = "KY">KY</option>
		<option value = "LA">LA</option>
		<option value = "MA">MA</option>
		<option value = "ME">ME</option>
		<option value = "MD">MD</option>
		<option value = "MI">MI</option>
		<option value = "MN">MN</option>
		<option value = "MO">MO</option>
		<option value = "MS">MS</option>
		<option value = "MT">MT</option>
		<option value = "NC">NC</option>
		<option value = "ND">ND</option>
		<option value = "NE">NE</option>
		<option value = "NH">NH</option>
		<option value = "NJ">NJ</option>
		<option value = "NM">NM</option>
		<option value = "OH">OH</option>
		<option value = "OK">OK</option>
		<option value = "OR">OR</option>
		<option value = "PA">PA</option>
		<option value = "RI">RI</option>
		<option value = "SC">SC</option>
		<option value = "SD">SD</option>
		<option value = "TN">TN</option>
		<option value = "TX">TX</option>
		<option value = "UT">UT</option>
		<option value = "VA">VA</option>
			<option value = "VT">VT</option>
		<option value = "WA">WA</option>
		<option value = "WI">WI</option>
		<option value = "WV">WV</option>
		<option value = "WY">WY</option>
		</select> 
  </td>   
<td><?PHP if(isset($z_message)){ echo "$z_message<br />";} ?><span style="color:#ff0000">*</span>Zip Code:<br />
          <input name="zipcode" type="text" style="width:90%" value="<?PHP echo "$zipcode"; ?>" /> 
</td>  
</tr>  
<tr class = "orderRow">
<td><?PHP if(isset($p_message)){ echo "$p_message<br />";} ?><span style="color:#ff0000">*</span>Phone ex: 123-623-6235<br />  
    <input name="phone" type="text" style="width:90%" value="<?PHP echo "$phone"; ?>" /> 
</td>
<td><?PHP if(isset($f_message)){ echo "$f_message<br />";} ?>  Fax:<br />   
    <input name="fax" type="text" style="width:90%" value="<?PHP echo "$fax"; ?>" /> 
    </td>
<td><?PHP if(isset($e_message)){ echo "$e_message<br />";} ?><span style="color:#ff0000">*</span>Email: <br />  
<input name="email" type="text" style="width:90%" value="<?PHP echo "$email"; ?>" />
</td>
</tr>
<tr class="orderRow">  
     <td colspan="3" align="center"><?PHP if(isset($pay_message)){ echo "$pay_message<br />";} ?><span style="color:#ff0000">*</span>Please choose method of payment: <br /> 
Check 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Check"){
echo "<input name=\"payment\" type=\"radio\" value=\"Check\" checked=\"checked\" />"; 
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Check\" />"; 
}
?>
   Money Order 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Money order"){
echo "<input name=\"payment\" type=\"radio\" value=\"Money order\" checked=\"checked\" />";
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Money order\" />";
}
?>
   PayPal 
<?PHP
IF (isset($_POST['payment']) &&	$_POST['payment']=="Paypal"){
echo "<input name=\"payment\" type=\"radio\" value=\"Paypal\" checked=\"checked\" />";
}
ELSE{
echo "<input name=\"payment\" type=\"radio\" value=\"Paypal\" />";
}
?>
</td>
</tr>
<tr>
<td colspan="3" align="center">	 <h2>  Pet Information </h2></td>
</tr>
<tr>
  <td><?PHP if(isset($pn_message)){ echo "$pn_message<br />";} ?><span style="color:#ff0000">*</span>Name: <br /> 
      <input name="petName" type="text" style="width:90%" value="<?PHP echo "$petName"; ?>" /> 
  </td>  
<td align="center"><span style="color:#ff0000">*</span>Age: <br />
<select name="age" style="width:20%">  
<?PHP
IF (isset($_POST['age'])){
echo "<option value=\"$postage\">$postage</option>";
}
$age=1;
  while($age <=20)
	{
	print "<option value=\"$age\">  $age</option>";
  $age ++; 
}
?>
</select>
</td>   
<td><?PHP if(isset($b_message)){ echo "$b_message<br />";} ?><span style="color:#ff0000">*</span>Breed:<br />
<select name = "breed">  
<?PHP
IF (isset($_POST['breed'])){
echo "<option value=\"$breed\">$breed</option>";
}
ELSE{  
echo "<option selected value =\"Please choose a breed\">Please choose a breed</option>"; 
}
?>
<option value = "I don't know">I don't know</option> 
<option value = "Affernpincher">Affernpincher</option>
<option value = "Afghan Hound">Afghan Hound</option> 
<option value = "Airedale Terrier">Airedale Terrior</option>
<option value = "Akita">Akita</option> 
<option value = "Alaskan Malamute">Alaskan Malamute</option>
<option value = "Standard American Eskimo Dog">Standard American Eskimo Dog</option>
<option value = "Miniature American Eskimo Dog">Miniature American Eskimo Dog</option>
<option value = "Toy American Eskimo Dog">Toy American Eskimo Dog</option>
<option value = "American Foxhound">American Foxhound</option>
<option value = "American Staffordshire Terrier">American Staffordshhire Terrier</option>
<option value = "American Water Spaniel">American Water Spaniel</option>
<option value = "Australian Shepherd Dog">Anatolian Shepherd Dog</option> 
<option value = "Australian Cattle Dog">Australian Cattle Dog</option>
<option value = "Australian Shepherd">Australian Shepherd</option> 
<option value = "Australian Terrier">Australia Terrier</option>
<option value = "Basenji">Basenji</option>
<option value = "Basset Hound">Basset Hound</option> 
<option value = "Beagle">Beagle</option>
<option value = "Bearded Collie">Bearded Collie</option>
<option value = "Beauceron">Beauceron</option> 
<option value = "Bedington Terrier">Bedington Terrier</option>
<option value = "Belgin Malinois">Belgin Malinois</option>
<option value = "Belgian Sheepdog">Belgian Sheepdog</option>
<option value = "Belgian Tervuren">Belgian Tervuren</option>
<option value = "Bernese Mountain Dog">Bernese Mountain Dog</option>
<option value = "Bichon Frise">Bichon Frise</option>
<option value = "Black and Tan Greyhound">Black and Tan Greyhound</option>
<option value = "Black Russian Terrier">Black Russian Terrier</option>
<option value = "Bloodhoung">Bloodhound</option>
<option value = "Border Collie">Border Collie</option>
<option value = "Border Terrier">Border Terrier</option>
<option value = "Borzoi">Borzoi</option>
<option value = "Boston Terrier">Boston Terrier</option>
<option value = "Bouvier des Flandres">Bouvier des Flandres</option>
<option value = "Boxer">Boxer</option>
<option value = "Briard">Briard</option>
<option value = "Brittany">Brittany</option>
<option value = "Brussels Griffon">Brussels Griffon</option>
<option value = "Bulldog">Bulldog</option>
<option value = "Bullmastiff">Bullmasttiff</option>
<option value = "Bull Terrier">Bull Terrier</option>
<option value = "Cairn Terrier">Cairn Terrier</option>
<option value = "Canaan Dog">Canaan Dog</option>
<option value = "Cardigan Welsh Corgi">Cardigan Welsh Corgi</option>
<option value = "Cavalier King Charles Spaniel">Cavalier King Charles Spaniel</option>
<option value = "Chesepeake Bay Retriever">Chesapeake Bay Retriever</option>
<option value = "Chilauhua">Chilauhua</option>
<option value = "Chinese Created">Chinese Crested</option>
<option value = "Chinese Shar-Pei">Chinese Shar-Pei</option>
<option value = "Chow Chow">Chow Chow</option>
<option value = "Clumber Spaniel">Clumber Spaniel</option>
<option value = "Cocker Spaniel">Cocker Spaniel</option>
<option value = "Collie">Collie</option>
<option value = "Curly-Coated Retrieve">Curly-Coated Retriever</option>
<option value = "Dachshound">Dachshund</option>
<option value = "Dalmation">Dalmation</option>
<option value = "Dandle Dimonnt">Dandie Dinmont Terrier</option>
<option value = "Doberman Pincher">Doberman Pincher</option>
<option value = "Dogue de Bordeaux">Dogue de Bordeaux</option>
<option value = "English Cocker Spaniel">English Cocker Spaniel</option>  
<option value = "English Foxhound">English Foxhound</option>
<option value = "English Setter">English Setter</option>
<option value = "English Springer">English Springer</option>
<option value = "English Toy Spaniel">English Toy Spaniel</option>
<option value = "Field Spaniel">Field Spaniel</option>
<option value = "Finnish Spitz">  Finnish Spitz</option>
<option value = "Flat-Coated Retriever">  Flat-Coated Retriever</option>
<option value = "French Bulldog">  French Bulldog</option>
<option value = "German Shepherd Dog"> German Shepherd Dog</option>
<option value = "German Shorthaired Pointer">German Shorthaired Pointer</option>
<option value = "German Wirehaired Pointer">German Wirehaired Pointer 
<option value = "Giant Schnauzer">Giant Schnauzer</option>
<option value = "Glen of Imaal Terrier">Glen of Imaal Terrier</option>
<option value = "Golden Retriever">Golden Retriever</option>
<option value = "Gorden Setter">Gorden Setter</option>
<option value = "Great Dane">Great Dane</option>
<option value = "Greater Swiss Mountain Dog">Greater Swiss Mountain Dog</option>
<option value = "Great Pyrenees">Great Pyrenees</option>
<option value = "Greyhound">Greyhound</option>
<option value = "Harrier">Harrier</option>
<option value = "Havanese">Havanese</option>
<option value = "Ibizen Hound">Ibizen Hound</option> 
<option value = "Irish Setter">Irish Setter</option>
<option value = "Irish Terrier">Irish Terrier</option>
<option value = "Irish Water Spaniel">Irish Water Spaniel</option>
<option value = "Irish Wolfhound">Irish Wolfhound</option>
<option value = "Italian Greyhound">Italian Greyhound</option>
<option value = "Jack Russell Terrier">Jack Russell Terrier</option>
<option value = "Japanese Chin">Japanese Chin</option>
<option value = "Keeshound">Keeshound</option>
<option value = "Kerry Blue TErrier">Kerry Blue Terrier</option>
<option value = "Komondor">Komondor</option>
<option value = "Kuvasz"> Kuvasz</option>
<option value = "Labradar Retriever">Labrador Retriever</option>
<option value = "Lakeland Terrier">Lakeland Terrier</option>
<option value = "Lhasa Apso">Lhasa Apso</option>
<option value = "Lowchen">Lowchen</option>
<option value = "Maltese">Maltese</option>
<option value = "Standard Manchester Terrier">Standard Manchester Terrier</option>
<option value = "Mastiff">Mastiff</option>
<option value = "Miniature Bull Terrier">Miniature Bull Terrier</option>
<option value = "Miniature Pinche">Miniature Pinscher</option>
<option value = "Miniature Poodle">Miniature Poodle</option>
<option value = "Miniature Schnauzer">Miniature Schnauzer</option>
<option value = "Mutt">Mutt</option>
<option value = "Neopolitan Mastiff">Neopolitan Mastiff</option>
<option value = "Newfoundland">Newfoundland</option> 
<option value = "Newfolk Terrier">Norfolk Terrier</option>
<option value = "Norwegian Elkhound">Norwegian Elkhound</option>
<option value = "Norwich Terrier">Norwich Terrier</option>
<option value = "Nova Scotia Duck Tolling Retriever">Nova Scotia Duck Tolling Retriever</option>
<option value = "Old English Sheepdog">Old English Sheepdog</option>
<option value = "Otterhound">Otterhound</option>
<option value = "Papillon">Papillon</option>
<option value = "Parson Russell Terrier">Parson Russell Terrier</option>
<option value = "Pekingese">Pekingese</option>
<option value = "Pembroke Welsh Corgi">Pembroke Welsh Corgi</option>
<option value = "Petit Basset Griffon Vendeen">Petit Basset Griffon Vendeen</option>
<option value = "Pharch Hound">Pharoh Hound</option>
<option value = "Plott">Plott</option>
<option value = "Pointer">Pointer</option>
<option value = "Polish Lowland Sheepdog">Polish Lowland sheepdog</option>
<option value = "Pomeranian"> Pomeranian</option>
<option value = "Portuguese Water Dog">Portuguese Water Dog</option> 
<option value = "Pug">Pug</option>
<option value = "Pull">Puli</option>
<option value = "Rhodesian Ridgeback">Rhodesian Ridgeback</option>
<option value = "Rottweiler">Rottweiler</option>
<option value = "ASaint Bernard">Saint Bernard</option>
<option value = "Saluki">Saluki</option>
<option value = "Samoyed">Samoyed</option>
<option value = "Schipperke">Schipperke</option>
<option value = "Scottish Doverhound">Scottish Deerhound</option>
<option value = "Scottish Terrier">Scottish Terrier</option>
<option value = "Sealyham Terrier">Sealyham Terrier</option>
<option value = "Shetland Sheepdog">Shetland Sheepdog</option>
<option value = "Shiba Inu">Shiba Inu</option>
<option value = "Shih Tzu">Shih Tzu</option>
<option value = "Siberian Husky">Siberian Husky</option>
<option value = "Silky Terrier">Silky Terrier</option>
<option value = "Skye Terrier">Skye Terrier</option> 
<option value = "Smooth Fox Terrier">Smooth Fox Terrier</option>
<option value = "Soft Coated Wheaten Terrier">Soft Coated wheaten Terrier</option>
<option value = "Spinone Italiano">Spinone Italiano</option>
<option value = "Staffordshire Bull Terrier">Staffordshire Bull Terrier</option>
<option value = "Standard Poodle">Standard Poodle</option>
<option value = "Standard Schnauer">Standard Schnauzer</option>
<option value = "Suseex Spaniel">Sussex Spaniel</option>
<option value = "Swedish Vallhound">Swedish Vallhund</option>
<option value = "Tibertan Mastiff">Tibetan Mastiff</option>
<option value = "Tibertan Spaniel">Tibetan Spaniel</option>
<option value = "Tibetan Terrier">Tibetan Terrier</option> 
<option value = "Toy Fox Terrier">Toy Fox Terrier</option> 
<option value = "Toy Manchester Terrier">Toy Manchester Terrier</option> 
<option value = "Toy Poodle">Toy Poodle</option>
<option value = "Vizela">Vizela</option>
<option value = "Weimaraner">Weimaraner</option>
<option value = "Welsh Springer Spaniel">Welsh Springer Spaniel</option>
<option value = "Welsh Terrier">Welsh Terrier</option> 
<option value = "West Highland White Terrier">West Highland White Terrier</option> 
<option value = "Whippet">Whippet</option>
<option value = "Wire Fox Terrier">Wire Fox Terrier</option> 
<option value = "Wirehaired Pointing Griffon">Wirehaired Pointing Griffon</option>
<option value = "Yorkshire Terrier">Yorkshire Terrier</option>
</select> 	

</td>
</tr>
<tr>
<td colspan="3" align="center"><b>Nutritional Needs:</b></td>
</tr>
<tr>
<td colspan="3" align="center"><textarea name="nutritionalNeeds" cols="17" rows="1" style="width:100%"><?PHP echo "$nutritionalNeeds"; ?></textarea></td>
</tr>
<tr>
<td colspan="3" align="center"><b>Special Instructions</b></td>
</tr>
<tr>
<td colspan="3" align="center"><textarea name="specialInstructions" cols="17" rows="1" style="width:100%"><?PHP echo "$specialInstructions"; ?></textarea></td>
</tr>
<tr>
<td colspan="3" align="center"><h2>Order Information</h2></td>
</tr>
<tr>
<td align="center"><input name="submit" type="submit" value="Order Treats!" /></td>
<td align="center"><span style="color:#ff0000">* Required Fields</span></td>
<td align="center"><input name="reset" type="submit" value="Cancel Order" /></td>
</tr>
</table>
<?PHP
IF (($showconfirmation=="t" && $thankyou=="f") || $thankyou=="t"){
echo "</div>";
}
IF ($showconfirmation=="t" && $thankyou=="f"){
//*****************************//
//Start order confirmation display
//*****************************//
//IF adding tax add here otherwise set to zero 0//
$tax=7.5; // ex: $tax=7.5;
//IF Adding shipping add here//
$shipping=3.5;  // ex: $shipping=3.5; as in $3.50
echo "<center>";
echo "<h2>Please Confirm your order</h2>";
echo "<table border=0 cellpadding=3 cellspacing=0>";
echo "<tr>";
echo "<td align=\"center\">";

IF (isset($_SESSION['cart'])){
//Add subtotal = 0 in case user refreshes page
$_SESSION['subtotal']=0;
foreach ($_SESSION['cart'] as $key => $value){
$listproducts = mysql_query("SELECT productname,cost FROM products WHERE id=$key");
WHILE($lstprod = mysql_fetch_array($listproducts)) {
$productname=$lstprod['productname'];
$productcost=$lstprod['cost'];
echo "<b>$productname</b> <br />Quantity ordered: $value<br />Cost each: $$productcost<br /><br />";
//get subtotals
$subtotal=$productcost*$value;

$_SESSION['subtotal']=($_SESSION['subtotal']+$subtotal);
}//$listproducts
}//foreach ($_SESSION['cart'] as $key => $value)
}//IF (isset($_SESSION['cart'])) </td>
echo "</tr>";
echo "<tr>";
echo "<td align=\"right\" style=\"border-top:1px solid;\">";
echo "Sub Total: $$_SESSION[subtotal]";
IF ($tax>0){
$TaxOnOrder=($_SESSION['subtotal']*$tax)/100;
$TaxOnOrder=number_format($TaxOnOrder, 2);
echo "<br />Tax: $$TaxOnOrder";  
}
IF ($shipping>0){
$shipping=number_format($shipping, 2); 				 
echo "<br />Shipping: $$shipping";  
}  
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"right\" style=\"border-top:1px solid;\">";
//Change depending or if using tax and shipping
IF ($tax>0 && $shipping>0){
$total=$_SESSION['subtotal']+$TaxOnOrder+$shipping;
}
IF ($tax==0 && $shipping>0){
$total=$_SESSION['subtotal']+$shipping;
}
IF ($tax>0 && $shipping==0){
$total=$_SESSION['subtotal']+$TaxOnOrder;
}
IF ($tax==0 && $shipping==0){
$total=$_SESSION['subtotal'];
}
echo "TOTAL: $$total";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\">";
echo "<input name=\"total\" type=\"hidden\" value=\"$total\" />";
echo "<input name=\"mode\" type=\"hidden\" value=\"Confirm\" />";
echo "<input name=\"submit\" type=\"submit\" value=\"Confirm Order\" />";
echo "</td>";
echo "</tr>";


echo "</table>";
echo "</center>";

}// end IF ($showconfirmation=="t")
IF ($thankyou=="t"){
echo "<h2>Thank you for your order!</h2>";
}
?>
</form> 
</body>
</html>

  • 3 weeks later...

I'm really sorry, but I'm still not getting this.  I decided just to try to transfer the quantity from the treats page to the checkout page for now but it still will not work. On the treats page if I enter a quantity and hit order treats, it will go to the check out page but it will not transfer the quantity.

 

treats.php

<?php
session_start();
if(!isset($_SESSION['quantity']))

{
  $_SESSION['quanity']=array(); //if there are no quantities selected, the array is empty
  if(is_array($_POST['quantity']))//if there are items in the cart
{
  echo $quantity;
  header("location: checkOut.php");
}
}
require_once("functions.php");
?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
td {
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #30C;
border-right-color: #30C;
border-bottom-color: #30C;
border-left-color: #30C;
}
#productCatalog {
width:400px;   
margin-right: auto;
margin-left: auto;
}
</style>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
logo();
navBar();
echo "<div id=\"productCatalog\">";
echo "<form action=\"checkOut.php\" method=\"post\" name=\"catalog\">";
  
DatabaseConnection();  

  $query = "SELECT * FROM treats"; 
        $result_set = mysql_query($query) or die(mysql_error());
$i = 0;

        echo "<table>";
        while ($row = mysql_fetch_array($result_set))
        {
	echo"<tr><td width=\"2s00px\"><img src=\"{$row['product_pic']}\" /></td><td width=\"200px\">{$row['product_title']}.<br /><br />{$row['product_Description']}.<br /> Price:  \${$row['price']}.<br /><br />Quantity <input name=\"quantity\" type=\"text\" size=\"2\" /></td></tr>";
        }
		echo "<tr>"; 
		echo "<td><input name=\"submit\" type=\"submit\" value=\"Proceed to Checkout\" />"; 
	echo "</table>";    
	echo "</form>";
echo "</div>";
footer();
?>
</body>
</html>

 

CheckOut.php

<?php
session_start();
require_once("functions.php");
DatabaseConnection(); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ordering doggy treats</title>
<link href="doggyTreats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#order {

margin-right: auto;
margin-left: auto;
}
.orderRow{ 
padding-bottom: 50px;
}
h2 {
text-align: center;
}

</style>
</head>
<body>
  
<?php        
logo();
navBar();
?>  
<form action="" method="post" name="checkOut">
<table id="order">
<tr class="orderRow">  
<td> First name:<br />
<input name="fname" type="text" size="10" maxlength="15" /></td>
    <td>Last name:  <br />
    <input name="lname" type="text" size="15" maxlength="30" /></td>
    <td>  Address:  <br />  
    <input name="address" type="text" size="30" /></td>
</tr>
<tr>
<tr class = "orderRow">
	<td>  City:  <br />
      <input name="city " type="text" size="15" maxlength="20" /> 
</td>
<td>   State:   <br />
          <select name = "state">  <option selected value ="Please choose a state"/>
		Please choose a state</option>
		<option value = "AL" />AL</option>
		<option value = "AK" />AK</option>
		<option value = "AR" />AR</option>
		<option value = "AZ" />AZ
		<option value = "CA" />CA
		<option value = "CO" />CO
		<option value = "CT" />CT
		<option value = "DE" />DE
		<option value = "DC" />DC
		<option value = "FL" />FL
		<option value = "GA" />GA
		<option value = "HI" />HI									


		<option value = "IA" />IA
		<option value = "ID" />ID
		<option value = "IL" />IL
		<option value = "IN" />IN
		<option value = "KS" />KS
		<option value = "KY" />KY
		<option value = "LA" />LA
		<option value = "MA" />MA
		<option value = "ME" />ME
		<option value = "MD" />MD
		<option value = "MI" />MI
		<option value = "MN" />MN
		<option value = "MO" />MO
		<option value = "MS" />MS
		<option value = "MT" />MT
		<option value = "NC" />NC
		<option value = "ND" />ND
		<option value = "NE" />NE
		<option value = "NH" />NH
		<option value = "NJ" />NJ
		<option value = "NM" />NM
		<option value = "OH" />OH
		<option value = "OK" />OK
		<option value = "OR" />OR
		<option value = "PA" />PA
		<option value = "RI" />RI
		<option value = "SC" />SC
		<option value = "SD" />SD
		<option value = "TN" />TN
		<option value = "TX" />TX
		<option value = "UT" />UT
		<option value = "VA" />VA
			<option value = "VT" />VT
		<option value = "WA" />WA
		<option value = "WI" />WI
		<option value = "WV" />WV
		<option value = "WY" />WY
		</select> 
  </td>   
<td>  Zip Code:<br />
          <input name="zipcode" type="text" size="5" maxlength="5" /> 
</td>  
</tr>  
<tr class = "orderRow">
<td> Phone  <br />  Please include area code <br />  
    <input name="phone" type="text" size="13" maxlength="13" /> 
</td>
<td>  Fax:<br />   
    <input name="" type="text" size="13" maxlength="13" /> 
    </td>
<td>   Email: <br />  
<input name="email " type="text" size="15" maxlength="30" />
</td>

</tr>
<tr class = "orderRow">  
     <td>   Please choose method of payment: <br /> 
Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" 

value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td>
</tr>
<tr>
<td colspan = "6">	 <h2>  Pet Information </h2></td>
</tr>
     <tr>
  <td>  Name: <br /> 
      <input name="petName" type="text" size="10" maxlength="20" /> 
  </td>  
<td>   Age: <br />
<select name="age">  
<?php
  for ($age =1; $age <=20; $age ++)
	{
	print "<option value=\"age\">  $age</option>"; 
}
?>   
</select>
</td>   
<td>   Breed:<br />
<select name = "breed">  <option selected value ="Please choose a breed"/>
		Please choose a breed
		    <option value = "I don't know" />I don't know 
			<option value = "Affernpincher" />Affernpincher
			<option value = "Afghan Hound" />Afghan Hound 
			<option value = "Airedale Terrier" /> Airedale Terrior
			<option value = "Akita" />  Akita 
			<option value = "Alaskan Malamute" />  Alaskan Malamute
			<option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog
			<option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo 		

                                 Dog
			<option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog
			<option value = "American Foxhound" />  American Foxhound
			<option value = "American Staffordshire Terrier" />  American Staffordshhire        

                         Terrier
			<option value = "American Water Spaniel" /> American Water Spaniel
			<option value = "Australian Shepherd Dog"/>  Anatolian Shepherd Dog 
			<option value = "Australian Cattle Dog"/>  Australian Cattle Dog
			<option value = "Australian Shepherd"/>  Australian Shepherd 
			<option value = "Australian Terrier" />  Australia Terrier
			<option value = "Basenji" />  Basenji
			<option value = "Basset Hound" />  Basset Hound 
			<option value = "Beagle" />  Beagle
			<option value = "Bearded Collie" />  Bearded Collie
			<option value = "Beauceron" />  Beauceron 
			<option value = "Bedington Terrier"/>  Bedington Terrier
			<option value = "Belgin Malinois"/> Belgin Malinois
			<option value = "Belgian Sheepdog"/>  Belgian Sheepdog
			<option value = "Belgian Tervuren"/>  Belgian Tervuren
			<option value = "Bernese Mountain Dog"/>  Bernese Mountain Dog
			<option value = "Bichon Frise"/>  Bichon Frise
			<option value = "Black and Tan Greyhound" />  Black and Tan Greyhound
			<option value = "Black Russian Terrier" />  Black Russian Terrier
			<option value = "Bloodhoung" />  Bloodhound
			<option value = "Border Collie" /> Border Collie
			<option value = "Border Terrier"/> Border Terrier
			<option value = "Borzoi"/>  Borzoi
			<option value = "Boston Terrier"/>  Boston Terrier
			<option value = "Bouvier des Flandres"/>  Bouvier des Flandres
			<option value = "Boxer"/>  Boxer
			<option value = "Briard"/>  Briard
			<option value = "Brittany" />  Brittany
			<option value = "Brussels Griffon" />  Brussels Griffon
			<option value = "Bulldog" /> Bulldog
			<option value = "Bullmastiff" /> Bullmasttiff
			<option value = "Bull Terrier" />  Bull Terrier
			<option value = "Cairn Terrier" />  Cairn Terrier
			<option value = "Canaan Dog" />  Canaan Dog
			<option value = "Cardigan Welsh Corgi" />  Cardigan Welsh Corgi
			<option value = "Cavalier King Charles Spaniel" />Cavalier King Charles   	    

                             Spaniel
			<option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever
			<option value = "Chilauhua" /> Chilauhua
			<option value = "Chinese Created" />  Chinese Crested
			<option value = "Chinese Shar-Pei" />  Chinese Shar-Pei
			<option value = "Chow Chow" />  Chow Chow
			<option value = "Clumber Spaniel" />  Clumber Spaniel
			<option value = "Cocker Spaniel" />  Cocker Spaniel
			<option value = "Collie" />  Collie
			<option value = "Curly-Coated Retrieve" />  Curly-Coated Retriever
			<option value = "Dachshound" />  Dachshund
			<option value = "Dalmation" /> Dalmation
			<option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier
			<option value = "Doberman Pincher" />  Doberman Pincher
			<option value = "Dogue de Bordeaux" /> Dogue de Bordeaux
			<option value = "English Cocker Spaniel" />  English Cocker Spaniel  
			<option value = "English Foxhound" />  English Foxhound
			<option value = "English Setter" />  English Setter
			<option value = "English Springer" /> English Springer
			<option value = "English Toy Spaniel" />  English Toy Spaniel
			<option value = "Field Spaniel" /> Field Spaniel
			<option value = "Finnish Spitz" />  Finnish Spitz
			<option value = "Flat-Coated Retriever" />  Flat-Coated Retriever
			<option value = "French Bulldog" />  French Bulldog
			<option value = "German Shepherd Dog" /> German Shepherd Dog
			<option value = "German Shorthaired Pointer"/>German Shorthaired Pointer
			<option value = "German Wirehaired Pointer" />  German Wirehaired Pointer 
			<option value = "Giant Schnauzer" /> Giant Schnauzer
			<option value = "Glen of Imaal Terrier" />  Glen of Imaal Terrier
			<option value = "Golden Retriever" /> Golden Retriever
			<option value = "Gorden Setter" /> Gorden Setter
			<option value = "Great Dane" /> Great Dane
			<option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog
			<option value = "Great Pyrenees" /> Great Pyrenees
			<option value = "Greyhound" /> Greyhound
			<option value = "Harrier"  /> Harrier
			<option value = "Havanese" />  Havanese
			<option value = "Ibizen Hound" /> Ibizen Hound 
			<option value = "Irish Setter" />  Irish Setter
			<option value = "Irish Terrier" /> Irish Terrier
			<option value = "Irish Water Spaniel" /> Irish Water Spaniel
			<option value = "Irish Wolfhound" />  Irish Wolfhound
			<option value = "Italian Greyhound" />  Italian Greyhound
			<option value = "Jack Russell Terrier" />  Jack Russell Terrier
			<option value = "Japanese Chin" />  Japanese Chin
			<option value = "Keeshound" />  Keeshound
			<option value = "Kerry Blue TErrier" />  Kerry Blue Terrier
			<option value = "Komondor" /> Komondor
			<option value = "Kuvasz" />  Kuvasz
			<option value = "Labradar Retriever" />  Labrador Retriever
			<option value = "Lakeland Terrier" />  Lakeland Terrier
			<option value = "Lhasa Apso" />  Lhasa Apso
			<option value = "Lowchen" />  Lowchen
			<option value = "Maltese" />  Maltese
			<option value = "Standard Manchester Terrier" /> Standard Manchester Terrier
			<option value = "Mastiff" />  Mastiff
			<option value = "Miniature Bull Terrier" />  Miniature Bull Terrier
			<option value = "Miniature Pinche" /> Miniature Pinscher
			<option value = "Miniature Poodle" /> Miniature Poodle
			<option value = "Miniature Schnauzer" />Miniature Schnauzer
			<option value = "Mutt" />Mutt
			<option value = "Neopolitan Mastiff" />Neopolitan Mastiff
			<option value = "Newfoundland&nbsp" /> Newfoundland 
			<option value = "Newfolk Terrier" />Norfolk Terrier
			<option value = "Norwegian Elkhound" /> Norwegian Elkhound
			<option value = "Norwich Terrier" /> Norwich Terrier
			<option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck 	    

                             Tolling Retriever
			<option value = "Old English Sheepdog" />Old English Sheepdog
			<option value = "Otterhound" /> Otterhound
			<option value = "Papillon" />Papillon
			<option value = "Parson Russell Terrier" /> Parson Russell Terrier
			<option value = "Pekingese" />Pekingese
			<option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi
			<option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen
			<option value = "Pharch Hound" />Pharoh Hound
			<option value = "Plott" /> Plott
			<option value = "Pointer" /> Pointer 
			<option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog
			<option value = "Pomeranian" /> Pomeranian
			<option value = "Portuguese Water Dog" />Portuguese Water Dog 
			<option value = "Pug" />Pug
			<option value = "Pull" />Puli
			<option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback
			<option value = "Rottweiler" />Rottweiler
			<option value = "ASaint Bernard" /> Saint Bernard
			<option value = "Saluki" /> Saluki
			<option value = "Samoyed" />Samoyed
			<option value = "Schipperke" />Schipperke
			<option value = "Scottish Doverhound" />Scottish Deerhound
			<option value = "Scottish Terrier" />Scottish Terrier
			<option value = "Sealyham Terrier" />Sealyham Terrier
			<option value = "Shetland Sheepdog" />Shetland Sheepdog
			<option value = "Shiba Inu" />Shiba Inu
			<option value = "Shih Tzu" />Shih Tzu
			<option value = "Siberian Husky" />Siberian Husky
			<option value = "Silky Terrier" />Silky Terrier
			<option value = "Skye Terrier" />Skye Terrier 
			<option value = "Smooth Fox Terrier" />Smooth Fox Terrier
			<option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier
			<option value = "Spinone Italiano" />Spinone Italiano
			<option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier
			<option value = "Standard Poodle" />Standard Poodle
			<option value = "Standard Schnauer" /> Standard Schnauzer
			<option value = "Suseex Spaniel"  />Sussex Spaniel
			<option value = "Swedish Vallhound" />Swedish Vallhund
			<option value = "Tibertan Mastiff" />Tibetan Mastiff
			<option value = "Tibertan Spaniel" />Tibetan Spaniel
			<option value = "Tibetan Terrier" />Tibetan Terrier 
			<option value = "Toy Fox Terrier" />Toy Fox Terrier 
			<option value = "Toy Manchester Terrier" />Toy Manchester Terrier 
                <option value = "Toy Poodle" />Toy Poodle
			<option value = "Vizela" />Vizela
			<option value = "Weimaraner" />Weimaraner
			<option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel
			<option value = "Welsh Terrier" />Welsh Terrier 
			<option value = "West Highland White Terrier" />West Highland White Terrier 
			<option value = "Whippet" />Whippet
			<option value = "Wire Fox Terrier" />Wire Fox Terrier 
			<option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon
			<option value = "Yorkshire Terrier" />Yorkshire Terrier 	
                	</select>

</td>
</tr>
<tr>
<td>Nutritional Needs:</td>
<td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea>
</td>
</tr>
<tr>
<td>Special Instructions</td>
<td><textarea name="specialInstructions" cols="17" rows="5"></textarea></td>
</tr>
<tr>
<td colspan = "6"><h2>Order Information</h2></td>
</tr>
<tr>   
<?php
echo $quantity;
/*foreach($key as $value){
	echo $value;
}*/
?>
</tr>
<tr>
<td> <input name="Submit" type="submit" value="Order Treats!" /></td><td><input name="reset" type="submit" value="Cancel Order" /> </td>
</tr>
</table>
</form>
</body>
</html>

Here's a stripped down, EXTREMELY BASIC version of a session-powered shopping cart. This is VERY easy to apply to any site, and can be quite compact using includes. Well commented.

 

<?php 

// This MUST COME before any output. I put this logic at the TOP of every shopping cart enabled page.
session_start();

// Check if the user wants to clear the cart, or if a cart doesn't exist yet. This should be checked FIRST.
if( isset($_GET['empty']) || !isset($_SESSION['cart']) )
$_SESSION['cart'] = array();

// Check if a user has added an item
if( isset($_POST['quantity']) && isset($_POST['id']) ) {
// This will make possibly things easier to follow
$id = $_POST['id'];
$quantity = $_POST['quantity'];
// &$var is assign by reference. Any changes to $cart will apply to $_SESSION['cart'].
// It's essentially creating two ways to access the same variable.
$cart = &$_SESSION['cart'];
// We will store the item and quantity in the array. $array[item] = quantity
// Check if the item is already in the cart
if( isset($cart[$id]) )
	// If so, add quantity to it. (int) forces $id to be returned as an integer.
	$cart[$id] += (int) $quantity;
else
	// Otherwise, set it to the quantity
	$cart[$id] = (int) $quantity;
// Destroy the reference to $cart to avoid acidentally screwing with it elsewhere in the script
unset( $cart );
}

// End shopping cart logic

// Start HTML document
?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>let's go shopping</title>
</head>
<body>
<div><h3>Items in cart:</h3><ul>
<?php

// Show the items in the cart
// Check if there are no items in cart
if( empty($_SESSION['cart']) )
echo '<li style="font-style: italic;">Empty</li>';
// Otherwise, loop through
else {
foreach( $_SESSION['cart'] as $id => $quantity ) {
	// Sanitize all outside-populated variables before display
	$id = htmlspecialchars($id); $quantity = htmlspecialchars($quantity);
	echo "<li>$quantity x of $id</li>";
}
}
// End items in the cart
?>
</ul></div>
<div>
<h3>Add products to cart</h3>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
	Item number: FOO-001 <input type="text" name="quantity" size="5" value="0">
	<input type="hidden" name="id" value="FOO-001">
	<input type="submit" value="Add">
</form>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
	Item number: FOO-052 <input type="text" name="quantity" size="5" value="0">
	<input type="hidden" name="id" value="FOO-052">
	<input type="submit" value="Add">
</form>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
	Item number: BAR-717 <input type="text" name="quantity" size="5" value="0">
	<input type="hidden" name="id" value="BAR-717">
	<input type="submit" value="Add">
</form>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
	Item number: FOO-102 <input type="text" name="quantity" size="5" value="0">
	<input type="hidden" name="id" value="FOO-102">
	<input type="submit" value="Add">
</form>
</div>
<a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>?empty=1">Empty the Cart</a>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.