-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
218 lines (173 loc) · 9.46 KB
/
checkout.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Event Essentials</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="Free HTML Templates" name="keywords">
<meta content="Free HTML Templates" name="description">
<!-- Favicon -->
<link href="img/favicon.ico" rel="icon">
<!-- Google Web Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
<!-- Libraries Stylesheet -->
<link href="lib/animate/animate.min.css" rel="stylesheet">
<link href="lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
<!-- Customized Bootstrap Stylesheet -->
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<section class="">
<?php
include 'includes/header.php';
?>
</section>
<?php
if(isset($_POST['save'])){
include 'includes/config.php';
$phonee = $_POST['phonee'];
$fdate = $_POST['fdate'];
$ldate = $_POST['ldate'];
$address = $_POST['address'];
$pin = $_POST['pin'];
$city = $_POST['city'];
$cust_id = $_SESSION['u_id'];
$fname= $_SESSION['fname'];
$lname= $_SESSION['lname'];
$email=$_SESSION['email'];
$phonee=$_SESSION['phone'];
$days=$ldate-$fdate;
function tdate($fdate,$ldate){
$diff=strtotime($ldate)-strtotime($fdate);
return abs($diff/86400);
}
$datediff=tdate($fdate,$ldate);
if (empty($ldate) || empty($fdate) || empty($address) || empty($pin) || empty($city)) {
echo "<script type=\"text/javascript\">
alert(\"Fill All The Fields.\");
window.location = \"checkout.php\";
</script>";
exit;
}
$today = new DateTime();
$fdatet = new DateTime($fdate);
if ($fdatet > $today) {
if ($fdate < $ldate) {
if (strlen((string)$pin) == 6) {
$qry = "INSERT INTO payment (cust_id, fname, lname, total_price, email, phoneno, from_date, last_date, address, pin, city, status)
VALUES ('$cust_id', '$fname', '$lname', '$total', '$email', '$phonee', '$fdate', '$ldate', '$address', '$pin', '$city', 'pending')";
$result = $conn->query($qry);
if ($result == TRUE) {
$sql1 = "SELECT order_id FROM payment WHERE from_date = '$fdate' AND last_date = '$ldate' AND cust_id = '$cust_id'";
$result2 = $conn->query($sql1);
$row = mysqli_fetch_assoc($result2);
$order_id = $row['order_id'];
echo "<script type=\"text/javascript\">
alert(\"Successfully Submitted\");
window.location.href = \"cnorder.php?dff=$datediff&oid=$order_id\";
</script>";
exit;
} else {
echo "<script type=\"text/javascript\">
alert(\"Failed. Try Again\");
window.location = \"checkout.php\";
</script>";
exit;
}
} else {
echo "<script type=\"text/javascript\">
alert(\"Enter a valid pin code.\");
window.location = \"checkout.php\";
</script>";
exit;
}
} else {
echo "<script type=\"text/javascript\">
alert(\"Enter a correct date.\");
window.location = \"checkout.php\";
</script>";
exit;
}
} else {
echo "<script type=\"text/javascript\">
alert(\"Enter a correct date.\");
window.location = \"checkout.php\";
</script>";
exit;
}
}
?>
<!-- Breadcrumb Start -->
<div class="container-fluid">
<div class="row px-xl-5">
<div class="col-12">
<nav class="breadcrumb bg-light mb-30">
<a class="breadcrumb-item text-dark" href="home.php">Home</a>
<span class="breadcrumb-item active">Checkout</span>
</nav>
</div>
</div>
</div>
<!-- Breadcrumb End -->
<!-- Checkout Start -->
<div class="container-fluid">
<div class="row px-xl-5">
<div class="col-lg-8">
<h5 class="section-title position-relative text-uppercase mb-3"><span class="bg-secondary pr-3">Billing Address</span></h5>
<form action="" method="post">
<div class="bg-light p-30 mb-5">
<div class="row">
<div class="col-md-6 form-group">
<label>Rent From </label>
<input class="form-control" name="fdate" type="date" placeholder="cherthala">
</div>
<div class="col-md-6 form-group">
<label>Rent Till </label>
<input class="form-control" name="ldate" type="date" placeholder="cherthala">
</div>
<div class="col-md-6 form-group">
<label>Address Line </label>
<input class="form-control" name="address" type="text" placeholder="cherthala">
</div>
<div class="col-md-6 form-group">
<label>City</label>
<input class="form-control" name="city" type="text" placeholder="Alappuzha">
</div>
<div class="col-md-6 form-group">
<label>Pincode Code</label>
<input class="form-control" name="pin" type="text" placeholder="000-253">
</div>
</div>
</div>
<div class="mb-5">
<button type="submit" name="save" class="btn btn-block btn-primary font-weight-bold py-3">Sumbit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Checkout End -->
<section class="">
<?php
include 'includes/footer.php';
?>
</section>
<!-- Back to Top -->
<a href="#" class="btn btn-primary back-to-top"><i class="fa fa-angle-double-up"></i></a>
<!-- JavaScript Libraries -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<script src="lib/easing/easing.min.js"></script>
<script src="lib/owlcarousel/owl.carousel.min.js"></script>
<!-- Contact Javascript File -->
<script src="mail/jqBootstrapValidation.min.js"></script>
<script src="mail/contact.js"></script>
<!-- Template Javascript -->
<script src="js/main.js"></script>
</body>
</html>