-
Notifications
You must be signed in to change notification settings - Fork 0
/
useraccountinfo.php
251 lines (192 loc) · 5.7 KB
/
useraccountinfo.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!-- This file displays the user/customer information after they log-in. The form at the bottom of the page accepts user credit/Master card information includng card number and expiry date, and further stores it in the database-->
<?php
session_start();
include("Functions.php");
$_SESSION['lastpage'] = "Booking.php";
$userId = $_SESSION["userid"];
?>
<!DOCTYPE html>
<html>
<head>
<style>
</style>
<title>Travel Experts</title>
<link rel="stylesheet" type="text/css" href="style.css">
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
<script>
function validateType(myForm)
{
var errorMessage = "";
var monthRE = /^(0?[1-9]|1[012])$/;
var yearRE = /^([1-9][0-9])$/;
if (myForm.elements[1].value == "FALSE")
{
errorMessage+="Please select a card type. ";
}
if(!yearRE.test(myForm.year.value))
{
errorMessage+="Please enter a valid year. ";
}
if(!monthRE.test(myForm.month.value))
{
errorMessage+="Please enter a valid month. ";
}
if(errorMessage == "")
{
return true;
}
else
{
alert(errorMessage);
return false;
}
}
</script>
</head>
<body>
<?php
include("header.php");
?>
<div id="main_container">
<!--WRITE YOUR CODE BELOW THIS LINE-->
<?php
$output = NULL;
if ($_SESSION["loggedin"] == "FALSE")
{
$_SESSION["lastpage"] = "useraccountinfo.php";
header("Location: login.php");
}
{
//connect to mysql
$mysqli = new mysqli("localhost", "root", "", "travelexperts");
//select quesry to fetch data
$result = $mysqli->query("SELECT * FROM customers WHERE CustomerId = $_SESSION[userid]");
$mysqli->close();
if ($result->num_rows > 0)
{
while ($rows = $result->fetch_assoc())
{
$CustId = $rows['CustomerId'];
$CustFirstName = $rows['CustFirstName'];
$CustLastName = $rows['CustLastName'];
$CustAddress = $rows['CustAddress'];
$CustCity = $rows['CustCity'];
$CustProv = $rows['CustProv'];
$CustPostal = $rows['CustPostal'];
$CustCountry = $rows['CustCountry'];
$CustHomePhone = $rows['CustHomePhone'];
$CustBusPhone = $rows['CustBusPhone'];
$CustEmail = $rows['CustEmail'];
$output = "<h1>Your Account Information</h1>
<form action='reghandler.php' method='post'>
<h3>
<table><tr>First Name:</tr> $CustFirstName <br/>
<tr>Last Name: $CustLastName </tr><br/>
<tr>Address: $CustAddress</tr> <br/>
<tr>City: $CustCity</tr> <br/>
<tr>Province: $CustProv</tr> <br/>
<tr>Postal Code: $CustPostal</tr> <br/>
<tr>Country: $CustCountry </tr><br/>
</br>
<tr>PHONE</tr> </br>
<tr>Home:</tr> $CustHomePhone <br/>
<tr>Business:</tr> $CustBusPhone <br/>
<tr>Email:</tr> $CustEmail <br/></table>
<input type='hidden' name='CustId' value='$CustId' /> </br>
<button type='submit' name='userAction' value='edit'>Edit account info</button>
<button type='submit' name='userAction' value='delete'>Delete account</button>
</h3>
</form></table>";
}
}
else {
$output = "Enter Username & Password";
}
}
echo $output;
?>
<input type="button" id="button" onclick="location.href='displayBooking.php';" value="View Bookings" />
<?php
//insert into db
/*$card = $mysqli->real_escape_string($_POST['CCName']);
$num = $mysqli->real_escape_string($_POST['CCNumber']);
$exp = $mysqli->real_escape_string($_POST['CCExpiry']);*/
function execute($userId)
{
if (isset($_POST['year']))
{
$mysqli = agencyConnect();
$datec = "20".($_POST['year'])."-".($_POST['month'])."-"."00 00:00:00";
$credit = "INSERT INTO creditcards (CCName, CCNumber, CCExpiry, CustomerId) VALUES ('$_POST[cardType]', '$_POST[cardNumber]', '$datec', '$userId')";
$insert = $mysqli->query($credit);
$mysqli->close();
return($insert);
}
}
//$datec = "20".($_POST['year']).($_POST['month'])."-"."00 00:00:00";
if (isset($_POST['year']))
{
if (execute($userId))
{
echo "<h1>Card successfully added</h1></br>";
}
else
{
print("Error: {$mysqli->errno} : {$mysqli->error}");
}
}
?>
<!--PAYMENT FORM-->
<form id="creditform" action="useraccountinfo.php" method="post" onsubmit="return validateType(this);">
<fieldset>
<legend>Secure Payment</legend> </br>
<img src="Images/checkout.png" width="150px" height="40px"/></br></br>
<label>Payment Type:</label>
<select name="cardType">
<option value="FALSE">Select Payment Type</option>
<option value="AMEX">AMEX</option>
<option value="MASTERCARD">MASTERCARD</option>
<option value="VISA">VISA</option>
<option value="DINERS">DINERS</option>
</select><br/><br/>
<label>Card Number:</label>
<input type="number" name="cardNumber" id="CCNumber" required="required"/> </br> </br>
<label>Expiry Date:</label>
<label>Year</label>
<input type="text" name="year" id="year" required="required"/> </br> </br>
<label>Month</label>
<input type="text" name="month" id="month" required="required"/> </br> </br>
<!--<select name="year">
<<option>Select Year</option>
<option value="15">15</option>
<option value="2">16</option>
<option value="3">17</option>
<option value="4">18</option>
</select>
<select name="month">
<!--<option>Select Month</option>
<option value="j">JAN</option>
<option value="f">FEB</option>
<option value="m">MAR</option>
<option value="a">APR</option>
<option value="ma">MAY</option>
<option value="ju">JUNE</option>
<option value="jl">JULY</option>
<option value="au">AUG</option>
<option value="s">SEPT</option>
<option value="o">OCT</option>
<option value="n">NOV</option>
<option value="d">DEC</option>
</select>-->
<input type="submit" value="Submit" /></br>
</fieldset>
</form>
<!--WRITE YOUR CODE ABOVE THIS LINE-->
</div>
<?php
include("footer.php");
?>
</body>
</html>