-
Notifications
You must be signed in to change notification settings - Fork 2
/
message.php
83 lines (57 loc) · 2.18 KB
/
message.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
<html>
<head></head>
<body>
<?php
// retrieve form data
$inputFirst = $_POST['msgFirst'];
$inputLast = $_POST['msgLast'];
$inputEmail = $_POST['msgEmail'];
$inputAddress1 = $_POST['msgAddress1'];
$inputAddress2 = $_POST['msgAddress2'];
$inputCity = $_POST['msgCity'];
$inputCountry = $_POST['msgCountry'];
$inputPostcode = $_POST['msgPostcode'];
$inputPhone = $_POST['msgPhone'];
$inputDOB = $_POST['msgYear'].'-'.$_POST['msgMonth'].'-'.$_POST['msgDay']; //$_POST['msgDOB'];
$inputPass = hash('ripemd160', $_POST['msgPass']);
$inputFullName = $inputFirst.' '.$inputLast;
//Check whether Address 2 was filled out
$inputFullAddress = $inputAddress2 != null ? $inputAddress1.', '.$inputAddress2 : $inputAddress1;
/*
The above code is identical to:
if ($inputAddress2 != null)
{
$inputFullAddress = $inputAddress1.', '.$inputAddress2;
}
else
{
$inputFullAddress = $inputAddress1;
}
*/
// use it
echo "Full Name : <i>$inputFullName</i><br />
Email Address : <i>$inputEmail</i><br />
Delivery Address : <i>$inputFullAddress, $inputCity, $inputCountry, $inputPostcode</i><br />
Phone No. : <i>$inputPhone</i><br />
Date of Birth : <i>$inputDOB</i><br />";
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "";
$db = "ECommerce";
// open connection
$connection = mysqli_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysqli_select_db($connection, $db) or die ("Unable to select database!");
// STUFF //
// create the queries
$query = "INSERT INTO Customer (CustomerFirstName, CustomerLastName, CustomerEmail, CustomerAddress1, CustomerAddress2, CustomerCity, CustomerCountry, CustomerPostcode, CustomerPhone, CustomerDOB, CustomerPass) VALUES ('$inputFirst','$inputLast','$inputEmail','$inputAddress1','$inputAddress2','$inputCity','$inputCountry','$inputPostcode','$inputPhone','$inputDOB','$inputPass')";
// execute queries and insert into database
mysqli_query($connection, $query) or die ("Error in query: $query.".mysqli_error($connection));
// close connection
mysqli_close($connection);
?>
<br />
<a href="index.php">Back to Index</a><br />
</body>
</html>