-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplaceorder.php
144 lines (108 loc) · 5.45 KB
/
placeorder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
require './conn.php';
session_start();
if($_SESSION['user_role'] == 'buyer' && isset($_SESSION['user_role'])) {
$bId = $_SESSION['buyer_ID'];
// Check if the form is submitted
if (isset($_POST['buy_now'])) {
$productID = $_GET['pId'];
$q = $_POST['quantity'];
$sql = "SELECT * FROM product WHERE product_ID = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("s", $productID);
$stmt->execute();
$result = $stmt->get_result();
if ($row = $result->fetch_assoc()){
$productName = $row['product_Name'];
$brandName = $row['product_Brand'];
$productPrice = $row['product_Price'];
$productImage = $row['product_Image'];
$desc = $row['product_Description'];
}
$querybuyer = "SELECT * FROM buyer WHERE buyer_ID = 1 ";
$resultbuyer = $con->query($querybuyer);
$row1 = $resultbuyer->fetch_assoc();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Click Cart</title>
<link href="./images/ico.png" rel="icon" type="image/png" />
<link rel="stylesheet" href="./css/placeorder.css">
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500;600;700&family=Oswald:wght@200&family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script type="text/javascript">
</script>
</head>
<body>
<?php include "./header.php" ?>
<div class="wrapper">
<div class="left-container">
<div class="details">
<form method="POST" action="process_order.php?pId=<?php echo $productID; ?>" >
<img class="p-image" src="./images/product/<?php echo $productImage; ?>" alt="Product Image">
<h2>Product Name: <?php echo $productName; ?></h2>
<h4><?php echo $brandName; ?></h4>
<br>
<p class="img-des"><?php echo $desc; ?></p>
<br>
<br><br>
<br><br>
<br><br>
<div class="input-group">
<label>Delivery Address:</label>
<input type="text" name="delivery_address" id="delivery_address" value="<?php echo $row1['address']; ?>" required><br>
</div>
<div class="input-group">
<label>Quantity:</label>
<input type="text" name="qty" id="qty" value="<?php echo $q; ?>" required><br>
</div>
<div class="input-group">
<label>Billing address:</label>
<input type="text" name="billing_address" id="billing_address" value="<?php echo $row1['address']; ?>" required><br><br>
</div>
<div class="input-group">
<label>Email:</label>
<input type="email" name="buyer_email" id="buyer_email" value="<?php echo $row1['email']; ?>" required><br>
</div>
</div>
<div class="details4"> Select Payment Method: </div>
<div class="items">
<div class="item"><i class="fa-solid fa-money-bill-1-wave"></i><input type="radio" name="payment_method" id="payment_method" value="cash" required/></div>
<div class="item"><i class="fa-brands fa-cc-visa"></i><input type="radio" name="payment_method" id="payment_method" value="visa" required/></div>
<div class="item"><i class="fa-brands fa-cc-mastercard"></i><input type="radio" name="payment_method" id="payment_method" value="master" required/></div>
<div class="item"><i class="fa-brands fa-cc-paypal"></i><input type="radio" name="payment_method" id="payment_method" value="paypal" required/></div>
</div>
</div>
<div class="right-container">
<h1>Order details</h1>
<div class="order-details">
<div class="title"> Item(1) </div>
<div class="value"><p><?php echo $productPrice ?></p></div>
</div>
<div class="order-details">
<div class="title"> Shipping </div>
<div class="value"> $5.00</div>
</div>
<div class="order-details">
<div class="title"><strong>Total($)</strong> </div>
<input class="totalbox" type="text" name="total" id="qty" value="<?php echo $cal = ($productPrice * $q) + 5; ?>" required><br>
</div>
<input class="placeorder-button" type="submit" name="place_order" value="Place Order">
</div>
</form>
</div>
<?php include "./footer.php" ?>
</body>
</html>
<?php
} else {
header('Location: login.php');
exit();
}
$con->close();
?>