-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_page.php
212 lines (187 loc) · 7.07 KB
/
user_page.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
<?php
//Include Data Base Config
include 'config.inc.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Atlas Corporation</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/navbar.css">
<link rel="stylesheet" type="text/css" href="css/user_page.css">
</head>
<body>
<!-- Main Bootstrap Container -->
<div class="container-fluid">
<!-- Nav Bar Container -->
<div class="row">
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-sm navbar-dark fixed-top" id="navigation">
<!-- Brand/Logo -->
<a class="navbar-brand" href="index.php">
<img src="images/Company-Logo.png" alt="Atlas Corporation" title="Atlas Corporation">
</a>
<!-- Pages -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="catalog.php">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="cart.php">Cart</a>
</li>
<li class="nav-item">
<a class="nav-link" href="weather.php">Weather</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact_us.html">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="log_in.html">Log In</a>
</li>
</ul>
</nav>
</div>
<?php
try
{
$m_FirstName = '';
$m_LastName = '';
$pdo = new PDO(DBCONNSTRING, DBUSER, DBPASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//Figure out if a user just registered the account or user is attempting log in
if(isset($_POST['user_password_reentry']))
{
//User is registering and logging in
$name = explode(" ", $_POST['full_name']);
$userName = $_POST['user_name'];
$email = $_POST['user_email'];
$password = $_POST['user_password'];
$query = "INSERT INTO users (FirstName, LastName, Username, Email, Password) VALUES ('" . $name[0] . "', '" . $name[1] . "', '" . $userName . "', '" . $email . "', '" . $password . "')";
$pdo->query($query);
$m_FirstName = $name[0];
$m_LastName = $name[1];
}
else if(isset($_POST['user_name']))
{
$userName = $_POST['user_name'];
$password = $_POST['user_password'];
$query = "SELECT Password FROM users WHERE Username = '" . $userName . "'";
$result = $pdo->query($query)->fetch();
if(isset($result['Password']))
{
$retPassword = $result['Password'];
if(strcmp($password, $retPassword) == 0)
{
$query = "SELECT FirstName, LastName FROM users where Username = '" . $userName . "'";
$result = $pdo->query($query)->fetch();
$m_FirstName = $result['FirstName'];
$m_LastName = $result['LastName'];
}
else
{
$m_FirstName = null;
$m_LastName = null;
}
}
else
{
$m_FirstName = null;
$m_LastName = null;
}
}
else
{
//Unknown invoker
$m_FirstName = null;
$m_LastName = null;
}
$pdo = null;
if(isset($m_FirstName) && isset($m_LastName))
{
//Authorized user
echo "<div class='row'>";
echo " <!-- Left Side Bar Content -->";
echo " <div class='col-md-3 side_bar'>";
echo " <div class='row user_icon'>";
echo " <img src='images/UserIcon.jpeg' alt='User' title='User'>";
echo " </div>";
echo " <!-- Company Logo -->";
echo " <div class='row company_logo'>";
echo " <img src='images/Company-Logo.png' alt='Atlas Corporation' title='Atlas Corporation'>";
echo " </div>";
echo " <!-- Possibility of adding some type of web api to display here -->";
echo " </div>";
echo " <!-- Main Content -->";
echo " <div class='col-md-9 main_content'>";
echo " <div class='row welcome'>";
echo " <h2 class='jumbotron welcome_phrase'>Hello, $m_FirstName $m_LastName!</h4>";
echo " </div>";
echo " <div class='row warning'>";
echo " <h4 class='jumbotron warning_phrase'>At Atlas Corporation we urge you and our employees to stay safe from COVID-19 with whatever means necessasry</h2>";
echo " </div>";
echo " <div class='row title'> ";
echo " <h4 class='jumbotron title_name'>Products</h2>";
echo " </div>";
echo " <div class='row products'>";
echo " <div class='col-md-3 product'>";
echo " <div class='card'>";
echo " <div class='card-body'>";
echo " <h5 class='card-title'>Pro<br>Book</h5>";
echo " <h6 class='card-subtitle mb-2 text-muted'>Laptop<h6>";
echo " <a href='product.php?productID=1' class='card-link'>Learn More</a>";
echo " </div> ";
echo " </div>";
echo " </div>";
echo " <div class='col-md-3 product'>";
echo " <div class='card'>";
echo " <div class='card-body'>";
echo " <h5 class='card-title'>Pro<br>Watch</h5>";
echo " <h6 class='card-subtitle mb-2 text-muted'>Watch<h6>";
echo " <a href='product.php?productID=2' class='card-link'>Learn More</a>";
echo " </div> ";
echo " </div>";
echo " </div>";
echo " <div class='col-md-3 product'>";
echo " <div class='card'>";
echo " <div class='card-body'>";
echo " <h5 class='card-title'>Pro<br>Phone</h5>";
echo " <h6 class='card-subtitle mb-2 text-muted'>Phone<h6>";
echo " <a href='catalog.php#pro_phone' class='card-link'>Learn More</a>";
echo " </div> ";
echo " </div>";
echo " </div>";
echo " <div class='col-md-3 product'>";
echo " <div class='card'>";
echo " <div class='card-body'>";
echo " <h5 class='card-title'>Pro<br>Monitor</h5>";
echo " <h6 class='card-subtitle mb-2 text-muted'>Monitor<h6>";
echo " <a href='catalog.php#pro_monitor' class='card-link'>Learn More</a>";
echo " </div> ";
echo " </div>";
echo " </div>";
echo " </div>";
echo " </div>";
echo "</div>";
}
else
{
//Unauthorized user
echo "<h1 class='jumbotron unauthorized_user'>Unauthorized User</h1>";
}
}
catch (PDOException $e)
{
//Unable to Connect to Data Base
echo "<h1 class='jumbotron unauthorized_user'>Unable to Authenticate</h1>";
}
?>
</div>
</body>
</html>