PHP MySQL Ecommerce Web Design Part 9

Postingan saya kali ini adalah membuat halaman clothing_billing.php beserta semua file-file pendukungnya
1. Buat file .PHP dengan nama clothing_billing.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file clothing_billing.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :


<?php
session_start(); //start session first thing in script
if(!isset($_SESSION["manager"])){
    header("location: clothing_cart.php");
    exit();
}
// Connect to the mySQL database
include "phpScripts/connect_to_mysql.php";
?>

<?php
// Error Reporting
error_reporting(E_ALL);
ini_set('display_errors','1');
?>

<?php
////////// dropdown city from shipping table ////////////////
$shipping_cities = mysql_query("SELECT DISTINCT CITY
FROM shipping ORDER BY id ASC");
    $dropcity = array();
    while($row = mysql_fetch_row($shipping_cities)){
        $dropcity[] = $row[0];   
    }
//////////////////////////////////////////////////////////////
if (isset($_SESSION['manager'])){
    $manager_name=($_SESSION['manager']);
}

$custsql=mysql_query("SELECT*FROM customer
WHERE customer_name='$manager_name' ") or die(mysql_error());
while($row = mysql_fetch_array($custsql)){
    $c_id=$row['c_id'];
    $bill_email=$row['email'];
    $bill_phone=$row['phone'];
    $bill_address=$row['address'];
    $bill_city=$row['city'];
} // closing while
?>

<?php
if(isset($_POST['pid'])){
    $pid=$_POST['pid'];
    $wasFound=false;
    $i=0;
    // if the cart session variable is not set or cart array is empty
    if(!isset($_SESSION["cart_array"])||count($_SESSION["cart_array"])<1){
        // RUN IF THE CART IS EMPTY OR NOT SET
        $_SESSION["cart_array"]=array(0=>array("item_id"=>$pid,"quantity"=>1));
    }else{
        //RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
        foreach($_SESSION["cart_array"]as $each_item){
            $i++;
            while(list($key, $value)= each($each_item)){
                if($key == "item_id" && $value == $pid){
                    // that item is in cart already so
                    // lets adjust its quantity using array_splice()
                    array_splice($_SESSION["cart_array"], $i-1, 1,
                    array(array("item_id" =>$pid, "quantity"
                    =>$each_item['quantity'] + 1)));
                    $wasFound=true;
                } // close if ...           
            } // close while ...
        } // close foreach ...
        if ($wasFound == false){
            array_push($_SESSION["cart_array"], array("item_id"
            => $pid, "quantity" => 1));               
        }   
    } //closing if ...
        header("location: cart.php");
        exit();
} // closing if
?>

<?php
// SECTION 5 (render the cart for the user to view)
$cartOutput = "";
$cartTotal = "";
$totalItem = "";
$totalQuantity = "";

if(!isset($_SESSION["cart_array"])
|| count ($_SESSION["cart_array"]) < 1) {
    $cartOutput = "<h3 align='center' style='color:blue'>
    Shopping Cart Anda Kosong</h3>";
} else {
    $i = 0;
    foreach ($_SESSION["cart_array"] as $each_item) {
        $item_id=$each_item['item_id'];
       
        $sqlStock=mysql_query("SELECT*FROM clothingStock
        WHERE stock_id='$item_id' LIMIT 1");
        while($row=mysql_fetch_array($sqlStock)) {
            $product_nameS=$row["product_name"];
            $colorS=$row["color"];
            $sizeS=$row["size"];
            $stock_amount0=$row["stock_amount"];
        }
        $sqlProd=mysql_query("SELECT*FROM clothing
        WHERE product_name='$product_nameS' LIMIT 1");
        // count the output amount
        $productCount=mysql_num_rows($sqlProd);
        if($productCount>0){
            while($row=mysql_fetch_array($sqlProd)) {
                $id=$row["id"];
                $product_price=$row["product_price"];
                $product_brand=$row["product_brand"];
                $category=$row["category"];
                $subcategory=$row["subcategory"];
                $product_details=$row["product_details"];
                $type=$row["type"];
                $bahan=$row["bahan"];
            } // closing while ...
        } // closing if ...
        // Menampilkan total harga dari satu item
        $total_price=$product_price*$each_item['quantity'];
        // Menampilkan total harga dari beberapa item               
        $cartTotal=$total_price+$cartTotal;   
        // Dynamic table row assembly
        $cartOutput .='<div id="bill_cart1" >';
        $cartOutput .='<div id="bill_prod1">
            <img class="goyang100" src="../clothing_stock_images1/'. $item_id .'.jpg"
            width="45" height="45" alt="x" class="one-edge-shadow"
            style="border-color:blue; border-style:solid; border-width:0px" />
            </br>
            '.$product_nameS.' 
            <font color="#0000FF" style="font-size:13px"> 
            '.$product_brand.'&nbsp;'.$category.' &nbsp; '.$type.' &nbsp;'.$subcategory.'  
            </font>
        </div>';
        $cartOutput .='<div id="bill_desc1">
            '.$product_details.'
        </div>';
        $cartOutput .='<div id="bill_uprice1">
            Rp&nbsp'.number_format($product_price,0,',','.').'
        </div>';
        $cartOutput .='<div id="bill_qty1">
            '. $each_item['quantity'].'
        </div>';
        $cartOutput .='<div id="bill_price1">
            Rp&nbsp'.number_format ($total_price,0,',','.').'
        </div>';
        $cartOutput .='</div>';
       
        $i ++;
    } // closing foreach ...
   
    $cartTotalF=number_format($cartTotal,0,',','.');
    // this for counting total all price in the shopping cart
    $_SESSION["cartTotal"]=$cartTotal;
    // for total number of item(product) selected in the shopping cart
    $item =$i ;
    $totalItem = $totalItem + $item;
    $_SESSION["totalItem"]=$totalItem;
    // untuk total quantity for all item:
    $totalQuantity = 0;
    if(isset($_SESSION['cart_array']) AND is_array(@$_SESSION['cart_array'])){
        foreach($_SESSION['cart_array'] AS $each_item){
            $totalQuantity =$totalQuantity + $each_item['quantity'];
        }
    }
    $_SESSION["totalQuantity"]=$totalQuantity;
} // closing if ...
?>

<?php
// jika $city dari $manager_name sama dengan city di tabel shipping
// maka shipping_price adalah $bill_price
$cust_city=mysql_query("SELECT*FROM shipping
WHERE city='$bill_city' ") or die(mysql_error());
while($row = mysql_fetch_array($cust_city)){
    $bill_price=$row['shipping_price'];
} // closing while ...

// biaya pengiriman jika memakai bill_price berdasarkan jumlah total qty
include("template_billing_biayaPengiriman.php");
////////////////////////////////////////////////////////////////////////

$bill_priceF=number_format($bill_priceCount,0,',','.');
$totalBuy1=$cartTotal + $bill_priceCount;
    $totalBuy1F=number_format($totalBuy1,0,',','.');
// menyimpan $_SESSION["cart_array"] dengan perintah serialize
$newstring = serialize( $_SESSION["cart_array"] );
// agar data-data pengiriman dari customer tidak hilang
if(isset($_SESSION['ship_name'])){
    $ship_name=$_SESSION['ship_name'];
}
if(isset($_SESSION['ship_phone'])){
    $ship_phone=$_SESSION['ship_phone'];
}
if(isset($_SESSION['ship_address'])){
    $ship_address=$_SESSION['ship_address'];
}               
if(isset($_SESSION['ship_city'])){
    $ship_city=$_SESSION['ship_city'];
          
    $shippingCity=mysql_query("SELECT*FROM shipping
    WHERE city='$ship_city' ") or die(mysql_error());
        while($row = mysql_fetch_array($shippingCity)){
            $ship_price=$row['shipping_price'];
      
            // biaya pengiriman jika memakai ship_price
            // berdasarkan jumlah total qty
            include("template_billing_biayaPengiriman2.php");
            ////////////////////////////////////////////
            $ship_priceF=number_format($ship_priceCount,0,',','.');
        } // closing while
    $totalBuy2=$cartTotal + $ship_priceCount;
    $totalBuy2F=number_format($totalBuy2,0,',','.');
} // closing if                  

// jika ada $_POST['placeOrder']), data-data akan dimasukkan
// ke tabel clothingOrders
if( isset($_POST['placeOrder'])){
    if (!empty($_SESSION["ship_city"])){
        // Add to MySQL database table
        $cust_order = mysql_query("INSERT INTO clothingOrders
        (c_id,order_detail,ship_name,ship_phone,ship_address,ship_city,
        shipPrice,date_added, status, date_shipped)
        VALUES ('$c_id','$newstring','$ship_name','$ship_phone',
        '$ship_address','$ship_city','$ship_priceCount', now(),
        'ORDER', now())")or die (mysql_error());
    }else{
        // Add to MySQL database table
        $cust_order = mysql_query("INSERT INTO clothingOrders
        (c_id,order_detail,ship_name,ship_phone,ship_address,ship_city,
        shipPrice,date_added, status, date_shipped)
        VALUES ('$c_id','$newstring','$manager_name','$bill_phone',
        '$bill_address','$bill_city','$bill_priceCount', now(),
        'ORDER', now())")or die (mysql_error());
    } // closing if
    // button "Place Order" diklik, proses penyimpanan
    // lalu kembali ke index.php dalam keadaan logout
    session_destroy(); 
    // Avoid re-adding item when refreshing the page
    header("location:index.php");
    exit();
} // closing if ...
?>

<!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>Clothing Billing</title>
<!---------------------- LINK --------------------------------->
    <?php include_once("template_links_head.php"); ?>
<!---------------------- END of LINK -------------------------->

<!---------------------- LINK FREE BEAVER SLIDER -------------------------->
     <?php include_once("template_js_beaverSlider_slideshow.php"); ?>
<!----------------------  END of LINK FREE BEAVER SLIDER ------------------>

</head>
<body>
<div id="wrapper">
    <div id="contentBill">
        <div id="headerP">
            <?php include_once("template_logoP.php");?>
        </div><!--- END headerP ---> 
        <br />     
        <div><center style="font-size:26px;
        font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
        BILLING</center></div>
               
        <div id="bill_to" align="left">
            <div id="bill_to_left">
                <span style="font-size:18px; margin-left:0px;
                font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
                Pesanan Atas Nama: </span>
                <br /> 
                <div style="font-size:15px; margin-left:0px;
                font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
                    Name:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if (!empty($_SESSION["manager"])){
                        echo "$manager_name";
                    } else{echo "";} ?>
                    </font> 
                    <br />
                    Phone:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if (!empty($_SESSION["manager"])){
                        echo "$bill_phone";
                    } else{    echo "";}?>
                    </font>
                    <br />
                    Address:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if (!empty($_SESSION["manager"])){
                        echo "$bill_address";
                    } else{    echo "";}?>
                    </font>
                    <br />
                    City:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if (!empty($_SESSION["manager"])){
                        echo "$bill_city";
                    } else{echo "";}?>
                    </font>
                    <br />
                </div>
            </div> <!--- END bill_to_left --->
           
            <div id="bill_to_right">
                <span style="font-size:18px; margin-left:0px;
                font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
                Pesanan Dikirim Ke: </span>
                <br /> 
                  <div style="font-size:15px; margin-left:0px;
                font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
                    Name:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if(isset($_SESSION['ship_name'])){
                        echo "$ship_name";
                    } else{    echo "";}?>
                    </font>
                    <br />
                    Phone:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if(isset($_SESSION['ship_phone'])){
                        echo "$ship_phone";
                    } else{echo "";}?>
                    </font>
                    <br />
                    Address:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if(isset($_SESSION['ship_address'])){
                        echo "$ship_address";
                    } else{echo "";}?>
                    </font>
                    <br />
                    City:
                    <font color='#0000FF' style='font-size:15px'>
                    <?php if(isset($_SESSION['ship_city'])){
                        echo "$ship_city";
                    } else{echo "";}?>
                    </font>
                    <br />
                </div>
            </div> <!--- END bill_to_right --->
        </div> <!--- END bill_to --->
       
        <div id="bill_cart" style="font-weight:bold">
            <div id="bill_prod">Product</div>
            <div id="bill_desc">Product Description</div>
            <div id="bill_uprice">Unit Price</div>
            <div id="bill_qty">Qty</div>
            <div id="bill_price">Total Price</div>
        </div> <!--- END bill_cart --->
         
        <?php echo $cartOutput;?>
       
        <div id="bill_tot" style="font-size:15px; font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif">
            <div id="bill_tot1">Sub Total Belanja &nbsp;:&nbsp;</div>
            <div id="bill_tot2">
                <?php if (!empty($_SESSION["cart_array"])){
                    echo 'Rp&nbsp'.$cartTotalF;
                }else{echo "";}
                ?>
            </div>
            <div id="bill_tot3">Discount &nbsp;:&nbsp;</div>
            <div id="bill_tot4"> </div>
            <div id="bill_tot5">Ongkos Kirim &nbsp;:&nbsp;</div>
            <div id="bill_tot6">
                <?php if (!empty($_SESSION["ship_city"])){
                       echo 'Rp&nbsp'.$ship_priceF;
                }else if (!empty($_SESSION["cart_array"])){
                       echo 'Rp&nbsp'.$bill_priceF;
                }else{echo "";}
                ?>
            </div>
            <div id="bill_tot7">Total &nbsp;:&nbsp;</div>
            <div id="bill_tot8">
                <?php if (!empty($_SESSION["ship_city"])){
                       echo 'Rp&nbsp'.$totalBuy2F;
                }else if (!empty($_SESSION["cart_array"])){
                       echo 'Rp&nbsp'.$totalBuy1F;
                }else{echo "";}
                ?>
            </div>
        </div> <!--- END bill_tot --->
        <br />
        <span style="font-size:13px;  font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif;  color:blue">
        Klik Shipping jika ingin dikirim ke alamat lain
        </span>
        <br />
         <a href="clothing_shipping.php"><input name="shipping"
        type="button" value="Shipping" style="font-size:15px;
        font-family:'Trebuchet MS', Arial, Helvetica, sans-serif"/></a>
        <br />
        <br />
        <span style="font-size:13px;  font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif;  color:blue">
        Klik Pesan untuk memesan
        </span>
        <br />
        <form id="billingForm" name="billingForm" method="post"
        action="clothing_billing.php" style="font-size:15px;
        font-family:'Trebuchet MS', Arial, Helvetica, sans-serif">
   
        <input type="submit" name="placeOrder" id="button" value="Pesan"
        style="font-size:15px; font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif"/>
         </form>
        <br/>
        <br/>
        <img src="../svg_images/small69black.svg" width="12" height="12"/>
        <?php
        echo "<font color=#ff0000>Jika penjumlahan bermasalah silahkan
        <a href='index.php'>Logout</a>  kemudian Login lagi<br/></font>";
        ?>
    </div><!--- END contentBill --->
</div><!--- END Wrapper --->

</body>
</html>



2. Buat file .PHP dengan nama template_billing_biayaPengiriman.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file template_billing_biayaPengiriman.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :

<?php
if ($_SESSION["totalQuantity"] < 2){
    $bill_priceCount=$bill_price/2 *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 1
&&  $_SESSION["totalQuantity"] < 5){
    $bill_priceCount=$bill_price *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 4
&&  $_SESSION["totalQuantity"] < 10){
     $bill_priceCount=($bill_price*2) *
     $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 9
&&  $_SESSION["totalQuantity"] < 15){
    $bill_priceCount=($bill_price*3) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 14
&&  $_SESSION["totalQuantity"] < 20){
    $bill_priceCount=($bill_price*4) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 19
&&  $_SESSION["totalQuantity"] < 25){
    $bill_priceCount=($bill_price*5) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 24
&&  $_SESSION["totalQuantity"] < 30){
    $bill_priceCount=($bill_price*6) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 29
&&  $_SESSION["totalQuantity"] < 35){
    $bill_priceCount=($bill_price*7) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 34
&&  $_SESSION["totalQuantity"] < 40){
    $bill_priceCount=($bill_price*8) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 39
&&  $_SESSION["totalQuantity"] < 45){
    $bill_priceCount=($bill_price*9) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 44
&&  $_SESSION["totalQuantity"] < 50){
    $bill_priceCount=($bill_price*10) *
    $_SESSION["totalQuantity"];
}
?>


3. Buat file .PHP dengan nama template_billing_biayaPengiriman2.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file template_billing_biayaPengiriman2.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :

<?php
if ($_SESSION["totalQuantity"] < 2){
    $ship_priceCount=$ship_price/2 *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 1
&&  $_SESSION["totalQuantity"] < 5){
    $ship_priceCount=$ship_price *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 4
&&  $_SESSION["totalQuantity"] < 10){
    $ship_priceCount=($ship_price*2) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 9
&&  $_SESSION["totalQuantity"] < 15){
    $ship_priceCount=($ship_price*3) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 14
&&  $_SESSION["totalQuantity"] < 20){
    $ship_priceCount=($ship_price*4) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 19
&&  $_SESSION["totalQuantity"] < 25){
    $ship_priceCount=($ship_price*5) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 24
&&  $_SESSION["totalQuantity"] < 30){
    $ship_priceCount=($ship_price*6) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 29
&&  $_SESSION["totalQuantity"] < 35){
    $ship_priceCount=($ship_price*7) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 34
&&  $_SESSION["totalQuantity"] < 40){
    $ship_priceCount=($ship_price*8) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 39
&&  $_SESSION["totalQuantity"] < 45){
    $ship_priceCount=($ship_price*9) *
    $_SESSION["totalQuantity"];
}else
if ($_SESSION["totalQuantity"] > 44
&&  $_SESSION["totalQuantity"] < 50){
    $ship_priceCount=($bill_price*10) *
    $_SESSION["totalQuantity"];
}
?>
       

4. Buat file .PHP dengan nama clothing_shipping.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file clothing_shipping.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :

<?php
session_start(); //start session first thing in script
// Connect to the mySQL database
include "phpScripts/connect_to_mysql.php";
?>

<?php
// Error Reporting
error_reporting(E_ALL);
ini_set('display_errors','1');
?>

<?php
////////////// dropdown city from shipping table///////////////
    $shipping_cities = mysql_query("SELECT DISTINCT CITY
    FROM shipping ORDER BY id ASC");
    $dropcity = array();
    while($row = mysql_fetch_row($shipping_cities)){
        $dropcity[] = $row[0];   
    }
///////////////////////////////////////////////////////////////
if (isset($_SESSION['manager'])){
    $manager_name=($_SESSION['manager']);
}
    $custsql=mysql_query("SELECT*FROM customer
    WHERE customer_name='$manager_name' ") or die(mysql_error());
        while($row = mysql_fetch_array($custsql)){
            $c_id=$row['c_id'];
            $bill_email=$row['email'];
            $bill_phone=$row['phone'];
            $bill_address=$row['address'];
            $bill_city=$row['city'];
        }
if(isset($_POST['shipUpdate'])){
    $_SESSION['ship_name']=$_POST['ship_name'];
    $_SESSION['ship_phone']=$_POST['ship_phone'];
    $_SESSION['ship_address']=$_POST['ship_address'];
    $_SESSION['ship_city']=$_POST['ship_city'];
}
?>

<!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>Clothing Shipping</title>
<!---------------------- LINK -------------------------->
    <?php include_once("template_links_head.php"); ?>
<!---------------------- END of LINK ------------------->

<!---------------------- LINK FREE BEAVER SLIDER -------------------------->
    <?php include_once("template_js_beaverSlider_slideshow.php"); ?>
<!----------------------  END of LINK FREE BEAVER SLIDER ----------------->

<!--- Validating shippingForm --->
    <?php include_once("validasi_cshipping.php"); ?>
<!--- END Validating shippingForm --->

</head>
<body>
<div id="wrapper">
    <div id="contentShip" class="one-edge-shadow">
        <div id="ship_to" align="left">
            <span style="font-size:18px; font-family:'Trebuchet MS',
            Arial, Helvetica, sans-serif">
            PESANAN DIKIRIM KE:
            </span>
            <br />
            <br />
            <form id="shippingForm" name="shippingForm" method="post" 
            action="clothing_shipping.php" enctype="multipart/form-data"
            style="font-size:15px; font-family:'Trebuchet MS',
             Arial, Helvetica, sans-serif">
            Name:
            <br />
            <input type="text" name="ship_name"  id="ship_name"
            placeholder="Name"  size="27" style="font-size:15px;
            font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;
            border:solid; border-width:1px; border-color:#999"/>
            <br />
            Phone:
            <br /> 
            <input  type="text"   name="ship_phone"  id="ship_phone" 
            placeholder="Phone"  size="27" style="font-size:15px; 
            font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;
            border:solid; border-width:1px; border-color:#999"/>
            <br />
            Address:
            <br />
            <span style="font-size:13px;  font-family:'Trebuchet MS',
            Arial, Helvetica, sans-serif; color:blue">
            Pastikan data alamat anda lengkap!</span>
            <br />
            <textarea  name="ship_address" id="ship_address" cols="25 " rows="3" 
              style="font-size:15px; font-family:'Trebuchet MS', Arial,
              Helvetica, sans-serif; border:solid; border-width:1px;
              border-color:#999"></textarea>
            <br />
            City:
            <br />
            <?php
            // dropdown city retrieved from data base (buatan RIAN)
            if(count($dropcity) <= 0){
                echo 'No results have been found.';
            } else { 
                echo '<select name="ship_city" id="ship_city"
                style="font-size:15px; font-family:Trebuchet MS,
                Arial, Helvetica, sans-serif">';
                foreach($dropcity as $city)
                echo "<option style='font-size:15px;
                font-family:Trebuchet MS, Arial, Helvetica, sans-serif'>
                $city</option>";
                echo '</select>';
            }
            ?>
            <br />
            <br />
            <?php
            // jika ada $_POST['shipUpdate'] maka button "Update" tidak terlihat    
            if(isset($_POST['shipUpdate'])){
            ?>
            <?php
            }else{
            ?>
               <span style="font-size:13px; font-family:'Trebuchet MS',
               Arial, Helvetica, sans-serif; color:blue">
               Klik Update untuk memastikan</span>
            <br />
                <input type="submit" name="shipUpdate" id="button" value="Update"
                style="font-size:15px; font-family:'Trebuchet MS', Arial,
                Helvetica, sans-serif"
                onclick="javascript:return validateshippingForm();" />
                <?php
            } // closing if ...
            ?>
           
            <?php
            // jika ada $_POST['shipUpdate'] maka button "Continue" terlihat    
            if(isset($_POST['shipUpdate'])){
            ?>
            <br />
            <br />
            <span style="font-size:13px; font-family:'Trebuchet MS',
            Arial, Helvetica, sans-serif; color:blue">
            Klik Continue untuk melanjutkan</span>
            <br />
            <a href="clothing_billing.php"><input name="Continue" type="button"
            value="Continue" style="font-size:15px; font-family:'Trebuchet MS',
            Arial, Helvetica, sans-serif"/></a>
            <?php
            }else{
            ?>
            <?php
            }
            ?>
            </form>
        </div><!--- END ship --->
    </div><!--- END contentShip --->
</div><!--- END Wrapper --->

</body>
</html>


5. Buat file .PHP dengan nama validasi_cshipping.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file validasi_cshipping.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :

<script type="text/javascript" language="javascript">
// By Adam Khoury @ www.developphp.com
function validateshippingForm ( ) {
    var isValid = true;
    if ( document.shippingForm.ship_name.value == "" ) {
    alert ( "Do not leave it blank!" );
    isValid = false;
    } else if ( document.shippingForm.ship_name.value.length < 8 ) {
            alert ( "Your name must be at least 8 characters long" );
            isValid = false;
    } else if ( document.shippingForm.ship_phone.value == "" ) {
            alert ( "Do not leave it blank!" );
            isValid = false;
    } else if ( document.shippingForm.ship_address.value == "" ) {
            alert ( "Do not leave it blank!" );
            isValid = false;
    } else if ( document.shippingForm.ship_city.value == "" ) {
            alert ( "Do not leave it blank!" );
            isValid = false;
    }
    return isValid;
}
</script>


6. Buat file .PHP dengan nama template_logoP.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file template_logoP.php di D:\TUTOR WEB\RIANKLIK\. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :

<div id="logoP">
    <a href="
http://192.168.88.111/index.php">
    <img src="logo_image/rianklik.png"
    width="281" height="60" alt="Rianklik"/>
    </a>
</div><!--- closing logoP --->


7. Buat file .PHP dengan nama create_clothingOrders_table.php di dalam folder phpScripts
Buka Notepad++, pilih File, klik Open, cari file create_clothingOrders_table.php di dalam folder phpScripts. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save:

<?php
// connect to your MySQL database here
require "connect_to_mysql.php";
// Create an sql command structure for creating a table
$sqlCommand = "CREATE TABLE clothingOrders (
    or_id int(11) NOT NULL auto_increment,
    c_id int(11),
    order_detail text(65535) NOT NULL,
    ship_name varchar(16) NOT NULL,
    ship_phone varchar(16) NOT NULL,
    ship_address varchar(255) NOT NULL,
    ship_city varchar(32) NOT NULL,
    shipPrice varchar(16) NOT NULL,
    date_added date NOT NULL,
    status varchar(11) NOT NULL,
    date_shipped date NOT NULL,
    PRIMARY KEY (or_id),

    FOREIGN KEY (c_id)
    REFERENCES customer(c_id)
)ENGINE = InnoDB";

if (mysql_query($sqlCommand)){
    echo "Your clothingOrders table has been created successfully!";
} else {
    echo "CRITICAL ERROR: clothingOrders table has not been created.";
}
?>

8. Buka Notepad++, pilih File, klik Open, cari file style.php di dalam folder styleCSS. Isikan sama seperti script warna biru di bawah lalu jangan lupa di-save :
/*--------------- billing----------------- */
#contentBill {
    -moz-border-radius: 8px 8px 8px 8px;  /* for Firefox */
    -webkit-border-radius: 8px 8px 8px 8px; /* for Webkit-Browsers */
    border-radius: 8px 8px 8px 8px; /* regular */
    opacity: 0.8;
    margin-right: auto;
    margin-left: auto;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    overflow: hidden;
    width: 698px;
    position: relative;
    display: block;
    border: 1px solid #CCC;
    padding-right: 30px;
    padding-bottom: 30px;
    padding-left: 30px;
    background-color: #FFF;
}
#bill {
    width: 680px;
    text-align: center;
    padding: 0px;
    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
}
#bill_to {
    width: 750px;
    overflow: hidden;
    margin: 0px;
    padding: 15px;
}
#bill_to_left {
    float: left;
    height: 140px;
    width: 295px;
    padding: 15px;
}
#bill_to_right {
    float: left;
    height: 140px;
    width: 295px;
    padding: 15px;
}
#ship_to {
    float: left;
    height: 420px;
    width: 235px;
    padding: 15px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}
#contentPrintout {
    -moz-border-radius: 8px 8px 8px 8px;  /* for Firefox */
    -webkit-border-radius: 8px 8px 8px 8px; /* for Webkit-Browsers */
    border-radius: 8px 8px 8px 8px; /* regular */
    opacity: 0.8;
    margin-right: auto;
    margin-left: auto;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    overflow: hidden;
    width: 718px;
    position: relative;
    display: block;
    border: 1px solid #CCC;
    padding-right: 40px;
    padding-bottom: 20px;
    padding-left: 0px;
}
#bill_cart {
    width: 720px;
    margin-top: 20px;
    overflow: hidden;
    position: relative;
    margin-right: auto;
    margin-left: auto;
}
#bill_prod {
    padding: 2px;
    float: left;
    width: 150px;
    text-align: center;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #ecf0f1;
    height: 30px;
}
#bill_desc {
    margin: 0px;
    float: left;
    width: 230px;
    text-align: center;
    padding: 2px;
    background-color: #ecf0f1;
    height: 30px;
}
#bill_uprice {
    text-align: center;
    margin: 0px;
    padding: 2px;
    float: left;
    width: 100px;
    background-color: #ecf0f1;
    height: 30px;
}
#bill_qty {
    text-align: center;
    margin: 0px;
    padding: 2px;
    float: left;
    width: 43px;
    background-color: #ecf0f1;
    height: 30px;
}
#bill_price {
    text-align: center;
    margin: 0px;
    padding: 2px;
    float: left;
    width: 120px;
    background-color: #ecf0f1;
    height: 30px;
}
#bill_cart1 {
    width: 720px;
    margin-right: auto;
    margin-left: auto;
    overflow: hidden;
    position: relative;   
}
#bill_prod1 {
    padding: 2px;
    width: 150px;
    text-align: center;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
    height: 130px;
    float: left;
}
#bill_desc1 {
    margin: 0px;
    float: left;
    width: 230px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    text-align: center;
    padding: 2px;
    background-color: #FFF;
    height: 130px;
}
#bill_uprice1 {
    text-align: center;
    margin: 0px;
    padding: 2px;
    float: left;
    width: 100px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    height: 130px;
}
#bill_qty1 {
    text-align: center;
    margin: 0px;
    padding: 2px;
    float: left;
    width: 43px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    height: 130px;
}
#bill_price1 {
    text-align: right;
    margin: 0px;
    float: left;
    width: 102px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 2px;
    padding-left: 2px;
    height: 130px;
}
#bill_tot {
    width: 720px;
    margin-right: auto;
    margin-left: auto;
    height: 150px;
    margin-bottom: 40px;
}
#bill_tot1 {
    padding: 2px;
    float: left;
    height: 30px;
    width: 538px;
    text-align: right;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
}
#bill_tot2 {
    text-align: right;
    margin: 0px;
    float: left;
    height: 30px;
    width: 102px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 2px;
    padding-left: 2px;
}
#bill_tot3 {
    padding: 2px;
    float: left;
    height: 30px;
    width: 538px;
    text-align: right;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
}
#bill_tot4 {
    text-align: right;
    margin: 0px;
    float: left;
    height: 30px;
    width: 102px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 2px;
    padding-left: 2px;
}
#bill_tot5 {
    padding: 2px;
    float: left;
    height: 30px;
    width: 538px;
    text-align: right;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
}
#bill_tot6 {
    text-align: right;
    margin: 0px;
    float: left;
    height: 30px;
    width: 102px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 2px;
    padding-left: 2px;
}
#bill_tot7 {
    padding: 2px;
    float: left;
    height: 30px;
    width: 538px;
    text-align: right;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
}
#bill_tot8 {
    text-align: right;
    margin: 0px;
    float: left;
    height: 30px;
    width: 102px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCC;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 2px;
    padding-left: 2px;
}
#bill_tot9 {
    float: left;
    height: 30px;
    width: 540px;
    text-align: left;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 30px;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 2px;
    padding-bottom: 20px;
    padding-left: 2px;
}
#bill_tot10 {
    text-align: right;
    margin: 0px;
    float: left;
    height: 30px;
    width: 103px;
    background-color: #FFF;
    padding-top: 2px;
    padding-right: 20px;
    padding-bottom: 20px;
    padding-left: 2px;
}

/*--------------- shipping----------------- */
#contentShip {
    -moz-border-radius: 8px 8px 8px 8px;  /* for Firefox */
    -webkit-border-radius: 8px 8px 8px 8px; /* for Webkit-Browsers */
    border-radius: 8px 8px 8px 8px; /* regular */
    opacity: 0.8;
    background-color: #FFFFFF;
    margin-right: auto;
    margin-left: auto;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    overflow: hidden;
    width: 270px;
    position: relative;
    display: block;
    padding: 10px;
}
#ship_to {
    float: left;
    height: 420px;
    width: 235px;
    padding: 15px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}


9. Upload semua file ke web server
10. Buka dengan browser 192.168.88.111/phpScripts/, klik file create_clothingOrders_table.php
11. Buka dengan browser 192.168.88.111
Setelah proses sampai pada halaman clothing_cart.php, klik Pesan




Gambar diatas adalah halaman clothing_billing.php dengan 2 item belanja, jika ingin merubah alamat tujuan pengiriman, klik Shipping


Isi nama, nomor hp, dan alamat tujuan pengiriman, lalu klik Update, kemudian klik Continue





sekarang tujuan pengiriman terisi dengan besarnya biaya pengiriman sesuai dengan daerah tujuan. kemudian klik Pesan.

Comments

Popular posts from this blog

Sepuluh Langkah Membuat Warnet