-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
223 lines (219 loc) · 8.61 KB
/
user.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
<?php
session_start();
// include_once '../connection/server.php';
include_once 'partials/_dbconnect.php';
if (!isset($_SESSION['sno'])) {
header("Location: index.php");
}
$res = mysqli_query($conn, "SELECT * FROM users WHERE id=" . $_SESSION['sno']);
$res2 = mysqli_query($conn, "SELECT * FROM recipe WHERE id=" . $_SESSION['sno']);
$userRow = mysqli_fetch_array($res, MYSQLI_ASSOC);
$numRows = mysqli_num_rows($res2);
?>
<!-- update -->
<?php
if (isset($_POST['submit'])) {
//variables
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$DOB = $_POST['DOB'];
$Gender = $_POST['Gender'];
$Phone = $_POST['Phone'];
$Email = $_POST['Email'];
$res = mysqli_query($conn, "UPDATE users SET FirstName='$FirstName', LastName='$LastName', dob='$DOB', Gender='$Gender', Phone=$Phone, Email='$Email' WHERE id=" . $_SESSION['sno']);
header('Location: user.php');
}
?>
<?php
$male = "";
$female = "";
if ($userRow['Gender'] == 'male') {
$male = "checked";
} elseif ($userRow['Gender'] == 'female') {
$female = "checked";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.104.2">
<title>Welcome <?php echo $userRow['FirstName']; ?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="dashboard.css" rel="stylesheet">
</head>
<body>
<!-- navigation -->
<header class="navbar navbar-dark sticky-top bg-primary flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="user.php">Welcome
<?php echo $userRow['FirstName']; ?>
</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</header>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3 sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.php">
<span data-feather="home" class="align-text-bottom"></span>
Home
</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="user.php">
<span data-feather="file" class="align-text-bottom"></span>
Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="recipe.php">
<span data-feather="coffee" class="align-text-bottom"></span>
Manage Recipe
</a>
</li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-uppercase">
<span>More options</span>
<a class="link-secondary" href="#" aria-label="Add a new report">
<span data-feather="plus-circle" class="align-text-bottom"></span>
</a>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item">
<a class="nav-link" href="partials/_logout.php">
<span data-feather="log-out"></span>
Log Out
</a>
</li>
</ul>
</div>
</nav>
<!-- navigation -->
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Profile</h1>
</div>
<h2 class="my-4"> Manage Your Profile</h2>
<div class="container my-4">
<div class="row my-4">
<div class="col-md-4 my-2">
<div class="card text-center" style="width: 14rem; height:23rem;">
<img src="images/user.jpg" class="card-img-top" style="height: 210px; width: 220px; " alt="image for this category">
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text"><strong><?php echo $userRow['FirstName']; ?> <?php echo $userRow['LastName']; ?></strong></p>
<p class="card-text">Total Dishes : <?php echo $numRows;?></p>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">Update Profile</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">Update profile</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- form start -->
<form action="<?php $_PHP_SELF ?>" method="post">
<table class="table table-hover table-bordered">
<tbody>
<tr>
<td>First Name:</td>
<td><input type="text" class="form-control" name="FirstName" value="<?php echo $userRow['FirstName']; ?>" /></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" class="form-control" name="LastName" value="<?php echo $userRow['LastName']; ?>" /></td>
</tr>
<tr>
<td>DOB</td>
<td>
<input class="form-control" type="date" id="DOB" name="DOB" placeholder="MM/DD/YYYY" type="text" value="<?php echo $userRow['dob']; ?>" />
</td>
</tr>
<tr>
<td>Gender</td>
<td>
<div class="radio">
<label><input type="radio" name="Gender" value="male" <?php echo $male; ?>>Male</label>
</div>
<div class="radio">
<label><input type="radio" name="Gender" value="female" <?php echo $female; ?>>Female</label>
</div>
</td>
</tr>
<tr>
<td>Phone number</td>
<td><input type="text" class="form-control" name="Phone" value="<?php echo $userRow['Phone']; ?>" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" class="form-control" name="Email" value="<?php echo $userRow['Email']; ?>" /></td>
</tr>
</tbody>
</table>
<input type="submit" name="submit" class="btn btn-success my-2 ms-2" value="Update Info">
</form>
</div>
</div>
</div>
</div>
<br /><br />
<div class="table-responsive">
<!-- Table -->
<table class="table table-hover table-bordered">
<tbody>
<tr>
<td>Date of Birth</td>
<td><?php echo $userRow['dob']; ?></td>
</tr>
<tr>
<td>Gender</td>
<td><?php echo $userRow['Gender']; ?></td>
</tr>
<tr>
<td>Phone</td>
<td><?php echo $userRow['Phone']; ?>
</td>
</tr>
<tr>
<td>Email</td>
<td><?php echo $userRow['Email']; ?>
</td>
</tr>
<tr>
<td>Account Created</td>
<td><?php echo $userRow['timestamp']; ?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</main>
</div>
<div class="container-fluid fixed-bottom bg-dark text-light mb-0">
<p class="text-center mb-0">
copyright © 2023 Recyippee | All rights reserved
</p>
</div>
</div>
<!-- Bootstrap Core JavaScript -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous">
</script> -->
<script src="feather.min.js"></script>
<script src="css/bootstrap.bundle.min.js"></script>
<script src="dashboard.js"></script>
</script>
</body>
</html>