· 8 years ago · Apr 30, 2018, 03:00 PM
1
2<!DOCTYPE html>
3<html>
4 <head>
5 <title>TV STORE JUSTIN CHUDLEY</title>
6 <?php
7 $servername = "localhost";
8 $username = "root";
9 $password = "root";
10 $conn = new mysqli($servername, $username, $password);
11 if($conn ->connect_error){
12 die("Could not connect: " . $conn->connect_error);
13 }
14 $conn->select_db("tv_store");
15
16 //CREATE DB IF db does not exist
17 $sql = 'CREATE DATABASE IF NOT EXISTS tv_store';
18 if($conn->query($sql) == TRUE){
19 //echo "Database created!\n";
20 }
21
22 else{
23 //echo 'Error: ' . $conn->error . "\n";
24 }
25
26 //CREATE TABLE IF table does not exist
27 $sql = "CREATE TABLE IF NOT EXISTS products
28 (
29 productNumber INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
30 productName VARCHAR(30) NOT NULL,
31 price VARCHAR(30) NOT NULL
32 )";
33
34 if ($conn->query($sql) == TRUE){
35 //echo "Table has been created!\n";
36 }
37 else{
38 //echo "Error creating table!";
39 }
40
41 //INSERT Data IF data is not already inserted
42 $sql = "INSERT IGNORE INTO products
43 (productNumber, productName,price)
44 VALUES ('1', 'Plasma','$500')";
45 if ($conn->query($sql) == TRUE){
46 //echo "insert has been created!\n";
47 }
48 else{
49 //echo "Error creating insert!";
50 }
51
52 $sql = "INSERT IGNORE INTO products
53 (productNumber, productName,price)
54 VALUES ('2', 'Flatscreen','$750')";
55 if ($conn->query($sql) == TRUE){
56 //echo "insert has been created!\n";
57 }
58 else{
59 //echo "Error creating insert!";
60 }
61
62 $sql = "INSERT IGNORE INTO products
63 (productNumber, productName,price)
64 VALUES ('3', '4k Retina','$1000')";
65 if ($conn->query($sql) == TRUE){
66 //echo "insert has been created!\n";
67 }
68 else{
69 //echo "Error creating insert!";
70 }
71
72 $sql = "INSERT IGNORE INTO products
73 (productNumber, productName,price)
74 VALUES ('4', 'Curved Flatscreen','$1500')";
75 if ($conn->query($sql) == TRUE){
76 //echo "insert has been created!\n";
77 }
78 else{
79 //echo "Error creating insert!";
80 }
81
82 $sql = "INSERT IGNORE INTO products
83 (productNumber, productName,price)
84 VALUES ('5', '5k Flatscreen','$2000')";
85 if ($conn->query($sql) == TRUE){
86 //echo "insert has been created!\n";
87 }
88 else{
89 //echo "Error creating insert!";
90 }
91
92 //Get all data into its own arrays
93 $product_numbers = array();
94 $product_names = array();
95 $prices = array();
96 $sql = "SELECT * FROM products";
97 $result = $conn->query($sql);
98 while($row = $result->fetch_assoc()){
99 $product_numbers[] = $row['productNumber'];
100 $product_names[] = $row['productName'];
101 $prices[] = $row['price'];
102 }
103
104 $conn->close();
105
106 ?>
107 </head>
108 <body>
109 <form name="QUIZ3" action="">
110 <p>Contact Information</p>
111 <input name="First Name" placeholder="First Name" type="text"><input name="Middle Initial"
112 placeholder="Middle Initial"
113 maxlength="1"
114 type="text"><input
115 name="Last Name"
116 placeholder="Last Name"
117 type="text"><input
118 name="Email"
119 placeholder="Email Address"
120 type="text"><input
121 name="Phone Number"
122 placeholder="Phone Number"
123 type="tel">
124 <p>Address</p>
125 <p><input name="Address" placeholder="Street" type="text"><input name="City"
126 placeholder="City"
127 type="text"><input
128 name="State"
129 placeholder="State"
130 type="text"><input
131 name="Zip"
132 placeholder="Zip Code"
133 maxlength="5"
134 type="text"></p>
135 <p>Email</p>
136 <p><input name="Email" placeholder="Email" type="text"></p>
137 <p>Phone Number</p>
138 <p><input name="Phone Number" placeholder="Phone Number" type="text"></p>
139 <input value="1" name="formselector" onclick="displayForm(this)" type="radio"> Credit Card <br>
140 <input value="2" name="formselector" onclick="displayForm(this)" type="radio">Paypal<br>
141 <input value="3" name="formselector" onclick="displayForm(this)" type="radio">Check<br>
142 <input value="4" name="formselector" onclick="displayForm(this)" type="radio">Bitcoin<br>
143 <input value="5" name="formselector" onclick="displayForm(this)" type="radio">Ether<br>
144 <input value="6" name="formselector" onclick="displayForm(this)" type="radio">Ripple
145 <p> Special Instructions</p>
146 <p><textarea name="text" placeholder="Have any special shipping Instructions?"></textarea>
147 </p>
148 <select name="values">
149 <option value=""><?php echo "Product Number $product_numbers[0]: $product_names[0]-$prices[0]"?></option>
150 <option value=""><?php echo "Product Number $product_numbers[1]: $product_names[1]-$prices[1]"?></option>
151 <option value=""><?php echo "Product Number $product_numbers[2]: $product_names[2]-$prices[2]"?></option>
152 <option value=""><?php echo "Product Number $product_numbers[3]: $product_names[3]-$prices[3]"?></option>
153 <option value=""><?php echo "Product Number $product_numbers[4]: $product_names[4]-$prices[4]"?></option>
154 </select>
155 <input name="OrderNumber" min="1" max="100" type="number"> <- Quantity<br>
156 <p>Payment: </p>
157 <br><br>
158 <button onclick ="calcTotal()">Submit Payment</button>
159 <input name="Reset" value="Reset Form" type="reset">
160 <p>
161 <script type="text/javascript">
162 function calcTotal(val){
163 var test = document.getElementByName('values');
164 window.alert("TEST");
165 }
166 function displayForm(val) {
167 if (val.value == "1") {
168 document.getElementById("creditCard").style.visibility = 'visible';
169 document.getElementById("payPal").style.visibility = 'hidden';
170 document.getElementById("check").style.visibility = 'hidden';
171 document.getElementById("BTC").style.visibility = 'hidden';
172 document.getElementById("ETH").style.visibility = 'hidden';
173 document.getElementById("XRP").style.visibility = 'hidden';
174 }
175 else if (val.value == "2") {
176 document.getElementById("creditCard").style.visibility = 'hidden';
177 document.getElementById("payPal").style.visibility = 'visible';
178 document.getElementById("check").style.visibility = 'hidden';
179 document.getElementById("BTC").style.visibility = 'hidden';
180 document.getElementById("ETH").style.visibility = 'hidden';
181 document.getElementById("XRP").style.visibility = 'hidden';
182
183 }
184 else if (val.value == "3") {
185 document.getElementById("creditCard").style.visibility = 'hidden';
186 document.getElementById("payPal").style.visibility = 'hidden';
187 document.getElementById("check").style.visibility = 'visible';
188 document.getElementById("BTC").style.visibility = 'hidden';
189 document.getElementById("ETH").style.visibility = 'hidden';
190 document.getElementById("XRP").style.visibility = 'hidden';
191 }
192 else if (val.value == "4") {
193 document.getElementById("creditCard").style.visibility = 'hidden';
194 document.getElementById("payPal").style.visibility = 'hidden';
195 document.getElementById("check").style.visibility = 'hidden';
196 document.getElementById("BTC").style.visibility = 'visible';
197 document.getElementById("ETH").style.visibility = 'hidden';
198 document.getElementById("XRP").style.visibility = 'hidden';
199 }
200 else if (val.value == "5") {
201 document.getElementById("creditCard").style.visibility = 'hidden';
202 document.getElementById("payPal").style.visibility = 'hidden';
203 document.getElementById("check").style.visibility = 'hidden';
204 document.getElementById("BTC").style.visibility = 'hidden';
205 document.getElementById("ETH").style.visibility = 'visible';
206 document.getElementById("XRP").style.visibility = 'hidden';
207 }
208 else if (val.value == "6") {
209 document.getElementById("creditCard").style.visibility = 'hidden';
210 document.getElementById("payPal").style.visibility = 'hidden';
211 document.getElementById("check").style.visibility = 'hidden';
212 document.getElementById("BTC").style.visibility = 'hidden';
213 document.getElementById("ETH").style.visibility = 'hidden';
214 document.getElementById("XRP").style.visibility = 'visible';
215 }
216 else {}
217 }
218
219 </script> </p>
220 </form>
221 <div style="visibility:hidden; position:relative" id="creditCard">
222 <form id="ccform"> <label>Enter your credit card details :</label> <br>
223 <br>
224 <dd>
225 <p>Name: <input id="ccname" name="ccname" value=""
226 type="text"> </p>
227 <p>Credit Card Vendor:
228 <select name="cctype" required="">
229 <option value="Visa">Visa</option>
230 <option value="American Express">American Express</option>
231 <option value="Discover">Discover</option>
232 <option value="Mastercard">Mastercard</option>
233 </select>
234 </p>
235 <p>Credit Card Number : <input minlength="16" maxlength="16" id="ccnumber" name="ccnumber" value="$ccnumber"type="text"></p>
236 <p>Experation:
237 <br><br> Month :
238 <select name="month" required="">
239 <option value="1">1</option>
240 <option value="2">2</option>
241 <option value="3">3</option>
242 <option value="4">4</option>
243 <option value="5">5</option>
244 <option value="6">6</option>
245 <option value="7">7</option>
246 <option value="8">8</option>
247 <option value="9">9</option>
248 <option value="10">10</option>
249 <option value="11">11</option>
250 <option value="12">12</option>
251 </select>
252 <span>Year :
253 <select name="year" required="">
254 <option value="2009">2009</option>
255 <option value="2010">2010</option>
256 <option value="2011">2011</option>
257 <option value="2012">2012</option>
258 </select>
259 </span> </p>
260 <p>CVC : <input minlength="3" id="cccvc" name="cccvc" value="" type="text">
261 </p>
262 </dd>
263 </form>
264 </div>
265
266 <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px"
267 id="payPal">
268 <form id="paypalform"> <label>Paypal Account:</label> <bx
269 <br>
270 <dd>Account: <input id="paypal" name="paypal" value="" type="text">
271 </dd>
272 </form>
273 </div>
274 <div style="visibility:hidden;position:relative;top:-90px;margin-top:-90px"
275 id="check">
276 <form id="checkform"> <label> Make all checks payable to Karl Marx. 123 Sieze the Means Street. </label> <br>
277 </form>
278 </div>
279 <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px"
280 id="payPal">
281 <br>
282 <form id="BTC"><label>Our BTC wallet adress is: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
283</label> <br>
284 <br>
285 </form>
286 </div>
287 <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px"
288 id="payPal">
289 <br><br><br><br>
290 <form id="ETH"><label>Our ETH wallet adress is: 0xe99356bde974bbe08721d77712168fa070aa8da4
291</label> <br>
292 <br>
293 </form>
294 </div>
295 <div style="visibility:hidden;position:relative;top:-110px;margin-top:-110px"
296 id="payPal"><br><br><br><br>
297 <form id="XRP"><label>Our XRP wallet adress is: rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh
298</label> <br>
299 <br>
300 </form>
301 </div>
302 </body>
303</html>