PHP MySQL Ecommerce Web Design Part 12

Postingan saya kali ini adalah membuat halaman shipping_resi.php beserta file-file pendukungnya.


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


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

<?php
// Gather this products full information for inserting automatically into
// the edit form which located below on this page
if(isset($_GET['pid'])){
    $targetID=$_GET['pid'];
 
    $sql=mysql_query("SELECT*FROM clothingOrders WHERE or_id='$targetID' LIMIT 1");
   
    $orderCount=mysql_num_rows($sql); // count the output amount
    if($orderCount>0){
        while($row=mysql_fetch_array($sql)){
        $or_id=$row["or_id"];
        $status=$row["status"];       
        } // closing while   
    }else{
        $order_list="The product is not listed!";
        exit();   
    } // closing if
} // closing if(isset($_GET['pid']))
?>


<!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>Shipping Resi</title>

<!---------------------- LINK -------------------------->
     <?php include_once("template_links_head2.php"); ?>
<!---------------------- closing LINK -------------------------->

</head>
<body>
<div id="wrapper">
    <div id="adminLogin" class="one-edge-shadow">
        <h2>SHIPPING RESI</h2>
        <form id="form1" name="form1" method="post" action="clothingShippedUpdate.php">
        Nomor Order:
        <br />
        <input name="username" type="text" id="username" disabled="disabled" value="<?php echo $or_id ?>"
        size="35" style="font-size:15px; font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif" />
        <br />
        Status:
        <br />
        <input name="status" type="text" id="status" disabled="disabled"
        value="<?php echo $status ?>"
        size="35" style="font-size:15px; font-family:'Trebuchet MS',
        Arial, Helvetica, sans-serif" />
        <br />
          Nomor Resi:
        <br />
        <input name="nomorresi" type="text" id="nomorresi" placeholder="Nomor Resi" size="35"
        style="font-size:15px; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif"/>
        <br />
        <br />
        <input name="thisID" type="hidden" value="<?php echo $or_id ?>"/>
        <input type="submit" name="shippingResi" id="button" value="OK"
        style="font-size:15px; font-family:'Trebuchet MS', Arial, Helvetica, sans-serif"/>
       
        </form>
    </div><!--- closing admin --->
</div><!--- closing Wrapper --->

</body>
</html>


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

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

<?php
$status0="PAID";
if (isset($_POST['shippingResi'])) {
   
    $nomorresi=mysql_real_escape_string($_POST['nomorresi']);
    $pid=mysql_real_escape_string($_POST['thisID']);
    $sql=mysql_query("SELECT*FROM clothingOrders WHERE or_id='$pid' LIMIT 1");
   
    $orderCount=mysql_num_rows($sql); // count the output amount
    if($orderCount>0){
        while($row=mysql_fetch_array($sql)){
        $or_id=$row["or_id"];   
        $c_id=$row["c_id"];
        $order_d=$row["order_detail"];
            $_SESSION["order_d"]=unserialize($row["order_detail"]);
               
        $ship_name=$row["ship_name"];
        $ship_phone=$row["ship_phone"];
        $ship_address=$row["ship_address"];
        $ship_city=$row["ship_city"];
        $shipPrice=$row["shipPrice"];
       
        $status=$row["status"];
       
        $date_added=strftime("%b %d, %y", strtotime($row["date_added"]));
   
        } // closing while   
    }else{
        $order_list="The product is not listed!";
        exit();   
    } // closing if

    // jika status="PAID" maka jalankan code dibawah
    if ($status0===$status){
        $sqlResi=mysql_query("INSERT INTO resi
        (or_id, nomor_resi, date_added)
        VALUES('$or_id','$nomorresi',now())")
        or die (mysql_error());
       
        $updateQuery = mysql_query ("UPDATE clothingOrders SET status = 'SHIPPED', date_shipped=now() WHERE or_id = '$or_id'")
        or die (mysql_error());
                   
        // jika status berubah menjadi PAID maka stock_amount akan berkurang
        //include_once("clothing_if_order_d_shippedUpdate.php");
       
        header("location:clothingOrder_list.php"); // Avoid re-adding item when refreshing the page
        exit();
    }else if ($status==="ORDER"){
        echo 'Sorry customer anda belum melakukan pembayaran order,
        <a href="clothingOrder_list.php">click here</a>';
        exit();       
       
    }else {
        echo 'Sorry order anda sudah dikirim,
        <a href="clothingOrder_list.php">click here</a>';
        exit();   
       
       
    } // closing if ($status0===$status)
} // closing if ...
?>

3. Buat file .PHP dengan nama clothing_konfirmasiA.php di D:\TUTOR WEB\RIANKLIK\
Buka Notepad++, pilih File, klik Open, cari file .PHP dengan nama clothing_konfirmasiA.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";

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

<?php
$status0="SHIPPED";

if(isset($_GET['pid'])){
  $targetID=$_GET['pid'];
 
  $sql=mysql_query("SELECT*FROM clothingOrders WHERE or_id='$targetID' LIMIT 1");
  $orderCount=mysql_num_rows($sql); // count the output amount
 
      if($orderCount>0){
        while($row=mysql_fetch_array($sql)){
            $status=$row["status"];
            if ($status0===$status){ // jika status="ORDER" maka jalankan code dibawah
                $updateQuery = mysql_query ("UPDATE clothingOrders SET status = 'ACCEPTED'
                WHERE or_id = '$targetID'")
                or die (mysql_error());
               
                // Avoid re-adding item when refreshing the page               
                header("location:customer_clothingOrder_list.php");
                exit();
            }else{
                // Avoid re-adding item when refreshing the page
                header("location:customer_clothingOrder_list.php");
                exit();
            }  // closing if ...
        }  // closing while loop
    }  // closing if ...
} // closing if ...

?>

4. Buat file .PHP dengan nama create_resi_table.php di dalam folder admin
Buka Notepad++, pilih File, klik Open, cari file Buat file .PHP dengan nama create_resi_table.php di dalam folder admin. 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 resi (
    id int(11) NOT NULL auto_increment,
    or_id varchar(24) NOT NULL,
    nomor_resi varchar(24) NOT NULL,
    date_added date NOT NULL,
    PRIMARY KEY (id)
)ENGINE = InnoDB";

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


5. Upload semua file ke web server
6. Buka dengan browser 192.168.88.111/phpScripts/, klik file create_resi_table.php
7. Buka dengan browser 192.168.88.111
Dari halaman index.php, klik Admin yang ada di halaman bagian bawah (footer), User Name: rian, Password: 654321 lalu klik Log In, klik Lihat Pesanan Clothing





Jika Status = PAID, klik pilihan Shipped



Di halaman clothingOrder_list.php, status berubah menjadi SHIPPED




Klik View






Jika customer/pembeli ingin melihat status pesanan:
Dari halaman index.php, klik Login yang ada di halaman bagian atas (header), Name: jakablack, Password: 654321 lalu klik Log In

Kemudian dari halaman index.php, klik Pria, klik Pakaian, klik Pesanan yang ada di halaman bagian atas (header)

Di halaman customer_clothingOrder_list.php, status berubah menjadi SHIPPED


Klik View



customer/pembeli meng-klik pilihan Accepted, jika produk yang dibeli sudah sampai dan diterima

 
 

Comments

Popular posts from this blog

Sepuluh Langkah Membuat Warnet