-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
224 lines (183 loc) · 10.8 KB
/
profile.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
<?php
require_once './includes/Init.php';
redirectIfNotAuthenticated();
$errorBag = [];
$messageBag = [];
$user = $database->select("users", '*', [
"id" => getUserID(),
]);
if (!$user) {
// perhaps we don't have the user data in the database
redirectIfNotAuthenticated();
} else {
// Okay, let's have the first result then
$user = $user[0];
}
if (getInput('submit') !== null) {
var_dump($_POST);
$fullName = getInput('full_name');
$email = getInput('email');
$age = getInput('age');
$sex = getInput('sex');
$phone = getInput('phone');
$facebook = getInput('facebook');
$twitter = getInput('twitter');
$union = getInput('union');
$upozila = getInput('upozila');
$thana = getInput('thana');
$district = getInput('district');
$division = getInput('division');
$update = $database->update("users", [
"full_name" => $fullName,
"email" => $email,
"age" => $age,
"sex" => $sex,
"contact_phone" => $phone,
"contact_facebook" => $facebook,
"contact_twitter" => $twitter,
"location_union" => $union,
"location_upozila" => $upozila,
"location_thana" => $thana,
"location_district" => $district,
"location_division" => $division,
], [
'id' => getUserID(),
]);
if ($update) {
// echo "created";
header('Location: /profile.php');
exit;
// var_dump($insert);
} else {
// var_dump($insert);
}
} else {
// todo: error message || validation library (not in this block)
}
include_once './partials/header.php';
?>
<main class="px-5 mx-auto my-3 ">
<!-- component -->
<div class="w-full relative mt-4 shadow-2xl rounded my-24 overflow-hidden">
<div class="top h-64 w-full bg-blue-600 overflow-hidden relative">
<img src="https://images.unsplash.com/photo-1503264116251-35a269479413?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80" alt="" class="bg w-full h-full object-cover object-center absolute z-0">
<div class="flex flex-col justify-center items-center relative h-full bg-black bg-opacity-50 text-white">
<img src="./assets/img/farhan-avatar.jpg" class="h-24 w-24 object-cover rounded-full">
<h1 class="text-2xl font-semibold"><?= ucFirst($user['full_name']) ?></h1>
<h4 class="text-sm font-semibold">Joined Since '20</h4>
</div>
</div>
<div class="grid grid-cols-12 bg-white ">
<div class="col-span-12 w-full px-3 py-6 justify-center flex space-x-4 border-b border-solid md:space-x-0 md:space-y-4 md:flex-col md:col-span-2 md:justify-start ">
<a href="profile.php" class="text-sm p-2 bg-indigo-900 text-white text-center rounded font-bold">Basic Information</a>
<a href="blood-profile.php" class="text-sm p-2 bg-indigo-200 text-center rounded font-semibold hover:bg-indigo-700 hover:text-gray-200">Blood Profile</a>
</div>
<div class="col-span-12 md:border-solid md:border-l md:border-black md:border-opacity-25 h-full pb-12 md:col-span-10">
<div class="px-4 pt-4">
<form method="POST" class="flex flex-col space-y-8">
<div>
<h3 class="text-2xl font-semibold">Basic Information</h3>
<hr>
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Full Name
</label>
<input type="text" name="full_name" value="<?= $user['full_name'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Email
</label>
<input type="email" name="email" value="<?= $user['email'] ?>" class="w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="flex flex-col space-y-4 md:space-y-0 md:flex-row md:space-x-4">
<div class="form-item w-full">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Age
</label>
<input type="number" name="age" value="<?= $user['age'] ?>" class="w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item w-full">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Sex
</label>
<select name="sex" class="w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
<option value="0"></option>
<option value="1">Male</option>
<option value="2">Female</option>
</select>
</div>
</div>
<div>
<h3 class="text-2xl font-semibold ">Contact Information</h3>
<hr>
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Mobile No.
</label>
<input type="tel" name="phone" value="<?= $user['contact_phone'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="flex flex-col space-y-4 md:space-y-0 md:flex-row md:space-x-4">
<div class="form-item w-full">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Facebook Username:
</label>
<input type="text" name="facebook" value="<?= $user['contact_facebook'] ?>" class="w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item w-full">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Twitter Username:
</label>
<input type="text" name="twitter" value="<?= $user['contact_twitter'] ?>" class="w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
</div>
<div>
<h3 class="text-2xl font-semibold ">Location Information</h3>
<hr>
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Union
</label>
<input type="text" name="union" value="<?= $user['location_union'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Upozila
</label>
<input type="text" name="upozila" value="<?= $user['location_upozila'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Thana
</label>
<input type="text" name="thana" value="<?= $user['location_thana'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
District
</label>
<input type="text" name="district" value="<?= $user['location_district'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="form-item">
<label for="name" class="mb-3 font-bold mb-1 text-xs tracking-wide text-gray-600 sm:text-sm">
Division
</label>
<input type="text" name="division" value="<?= $user['location_division'] ?>" class=" w-full py-2 px-2 placeholder-gray-400 border rounded sm:text-base focus:border-gray-700 focus:outline-none">
</div>
<div class="mt-6">
<button type="submit" value="submit" name="submit" class="flex w-full items-center justify-center px-4 py-3 text-sm text-gray-100 uppercase bg-gray-700 rounded cursor-pointer hover:bg-gray-800 focus:bg-gray-800 focus:outline-none" type="submit">
<span class="ml-3">Save</span>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</main>
<?php
include_once './partials/footer.php';
?>