-
Notifications
You must be signed in to change notification settings - Fork 0
/
S06_Customer_Registration.php
213 lines (191 loc) · 5.99 KB
/
S06_Customer_Registration.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
<?php
//php created by Justin Senia
//starts session to hold shopping cart items
session_start();
if (!isset($_SESSION['DBShoppingCart'])){
$_SESSION['DBShoppingCart'] = array();
$_SESSION['TotBooksInCart'] = 0;
$_SESSION['TotPrice'] = 0.00;
$_SESSION['UserID'] = "";
$_SESSION['UserInfo'];
$_SESSION['SearchFor'] = "";
$_SESSION['SearchOn'] = "";
$_SESSION['Category'] = "";
$_SESSION['ISBN'] = "";
$_SESSION['CCTemp'] = "";
$_SESSION['CCTempNum'] = "";
}
if (isset($_POST['firstname']))
{
//Joseph Galbreath created/edited the following
// Based on following tutorial
//https://www.eduonix.com/blog/web-programming-tutorials/phpmysql-and-html-forms/
//can be re-enabled for testing/verification purposes
//print_r($_POST);
// This is where I learned how connect with a database via PHP
//https://coolestguidesontheplanet.com/how-to-connect-to-a-mysql-database-with-php/
//Step1
$db = mysqli_connect('localhost','201709_471_g01','8SUH3swJoLLEHzxPNEih','201709_471_g01')
or die('Error connecting to MySQL server.');
// All code below is based on following tutorial
// https://www.eduonix.com/blog/web-programming-tutorials/phpmysql-and-html-forms/
// create a variable
$username=$_POST['username'];
$pin=$_POST['pin'];
$retype_pin=$_POST['retype_pin'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$credit_card=$_POST['credit_card'];
$card_number=$_POST['card_number'];
$expiration=$_POST['expiration'];
//Execute the query
mysqli_query($db, "INSERT INTO 201709_471_g01.Customer (CustomerUsername,CustPIN,FName,LName,CustAddress,City,State,Zip,CCNumber,CCName,CCExpDate) VALUES('$username','$pin','$firstname','$lastname','$address','$city','$state','$zip','$card_number','$credit_card','$expiration')");
//can be re-enabled for testing verification purposes
/*
if(mysqli_affected_rows($db) > 0)
{
echo "<p>Employee Added</p>";
//echo "<a href="index.html">Go Back</a>";
}
else {
echo "Employee NOT Added<br />";
echo mysqli_error ($db);
}
*/
header("Location: http://db2.emich.edu/~201709_cosc471_group01/S01_Welcome.php");
}
?>
<!-- visual design by Alexander Martens and Privithiraj Narahari
Html/css created by Justin Senia
Forms & php created and/or compiled for sql integration by Joseph Galbreath-->
<html>
<head>
<script>
//Made by Justin Senia: modifies history to prevent refresh/redirect errors
window.onload = function()
{
history.replaceState("", "", "S06_Customer_Registration.php");
}
</script>
<title> Customer Registration - 3-B.com </title>
</head>
<body>
<table align="center" style="border:2px solid blue;">
<tbody>
<tr>
<!-- Form tag set up base on tutorial
https://www.eduonix.com/blog/web-programming-tutorials/phpmysql-and-html-forms/ -->
<form id="register" method="POST" action="S06_Customer_Registration.php">
<td align="right">
Username<span style="color:red">*</span>:
</td>
<td align="left" colspan="3">
<input type="text" id="username" name="username" placeholder="Enter your username">
</td>
</tr>
<tr>
<td align="right">
PIN<span style="color:red">*</span>:
</td>
<td align="left">
<input type="password" id="pin" name="pin">
</td>
<td align="right">
Re-type PIN<span style="color:red">*</span>:
</td>
<td align="left">
<input type="password" id="retype_pin" name="retype_pin">
</td>
</tr>
<tr>
<td align="right">
Firstname<span style="color:red">*</span>:
</td>
<td colspan="3" align="left">
<input type="text" id="firstname" name="firstname" placeholder="Enter your firstname">
</td>
</tr>
<tr>
<td align="right">
Lastname<span style="color:red">*</span>:
</td>
<td colspan="3" align="left">
<input type="text" id="lastname" name="lastname" placeholder="Enter your lastname">
</td>
</tr>
<tr>
<td align="right">
Address<span style="color:red">*</span>:
</td>
<td colspan="3" align="left">
<input type="text" id="address" name="address">
</td>
</tr>
<tr>
<td align="right">
City<span style="color:red">*</span>:
</td>
<td colspan="3" align="left">
<input type="text" id="city" name="city">
</td>
</tr>
<tr>
<td align="right">
State<span style="color:red">*</span>:
</td>
<td align="left">
<select id="state" name="state">
<option selected="" disabled="">select a state</option>
<option>Michigan</option>
<option>California</option>
<option>Tennessee</option>
</select>
</td>
<td align="right">
Zip<span style="color:red">*</span>:
</td>
<td align="left">
<input type="text" id="zip" name="zip">
</td>
</tr>
<tr>
<td align="right">
Credit Card<span style="color:red">*</span>
</td>
<td align="left">
<select id="credit_card" name="credit_card">
<option selected="" disabled="">select a card type</option>
<option>VISA</option>
<option>MASTER</option>
<option>DISCOVER</option>
</select>
</td>
<td colspan="2" align="left">
<input type="text" id="card_number" name="card_number" placeholder="Credit card number">
</td>
</tr>
<tr>
<td colspan="2" align="right">
Expiration Date<span style="color:red">*</span>:
</td>
<td colspan="2" align="left">
<input type="text" id="expiration" name="expiration" placeholder="MM/YY">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" id="register_submit" name="register_submit" value="Register">
</td>
<td colspan="2" align="center">
<input type="submit" id="donotregister" name="donotregister" value="Don't Register">
</td>
</form>
</tr>
</tbody>
</table>
</body>
</html>