-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_user.php
291 lines (222 loc) · 8.84 KB
/
manage_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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
include 'db_connect.php';
$qry = $conn->query("SELECT * FROM users where id = ".$_GET['id'])->fetch_array();
foreach($qry as $k => $v){
$$k = $v;
}
?>
<style>
img {
max-width: 150px;
margin:2%;
}
@media
only screen and (max-width: 700px),
(min-device-width: 768px) and (max-device-width: 1024px) {
.container{
width:100%;
}
.hik{
justify-content:center;
}
}
</style>
<body class="bg-gradient-primary">
<div class="container">
<!-- Outer Row -->
<div class="col-xl-12 col-xl-12 col-md-12">
<div class="card o-hidden border-0 shadow-lg my-2">
<div class="card-body p-0">
<div class="p-2">
<div class="text-center">
<h1 class="h4 text-gray-900 mb-4">Mon profil</h1>
</div>
<?php
error_reporting(0);
?>
<?php include 'db_connect.php' ?>
<?php
$msg = "";
// If upload button is clicked ...
if (isset($_POST['upload'])) {
$filename = $_FILES["uploadfile"]["name"];
$tempname = $_FILES["uploadfile"]["tmp_name"];
$folder = "image/".$filename;
// Get all the submitted data from the form
$md = $_GET['id'];
$sql = "INSERT INTO image (filename,upload,userdi) VALUES ('$filename', NOW(),'$md')";
// Execute query
mysqli_query($conn, $sql);
// Now let's move the uploaded image into the folder: image
if (move_uploaded_file($tempname, $folder)) {
$msg = "Image uploaded successfully";
}else{
$msg = "Failed to upload image";
}
}
?>
<div id="content">
<?php
$img = '3135715.png';
$md = $_GET['id'];
$im = $conn->query("SELECT filename, userdi from image where userdi = '".$md."' ORDER BY id DESC LIMIT 1");
while ($row = $im->fetch_assoc()) :
$img = $row['filename']
?>
<?php endwhile; ?>
<title>Modifier utilisateur</title>
<link rel="stylesheet" type= "text/css" href ="style.css"/>
<form method="POST" action="" enctype="multipart/form-data">
<div class="hik">
<img src="image/<?php echo $img; ?>"/>
<input type="file" name="uploadfile" value=""/>
<button type="submit" name="upload" class="btn btn-outline-primary">Importer</button>
</div>
</form>
<form action="uploadu.php" class="needs-validation" id="manage_user" method="post" novalidate>
<input type="hidden" name="id" value="<?php echo isset($id) ? $id : '' ?>">
<div class="form-group mb-3">
<label class="form-label" for="validationCustom01">Prénom</label>
<input type="text" class="form-control" name="firstname" id="validationCustom01" placeholder="Nom" value="<?php echo isset($firstname) ? $firstname : '' ?>" required>
<div class="valid-feedback">
Looks good!
</div>
</div>
<div class="form-group mb-3">
<label class="form-label" for="validationCustom02">Nom</label>
<input type="text" class="form-control" id="validationCustom02" name="lastname" placeholder="Prénom" value="<?php echo isset($lastname) ? $lastname : '' ?>" required>
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<label class="form-label" for="validationCustomUsername">Entreprise</label>
<div class="input-group">
<input type="text" class="form-control" name="middlename" id="validationCustomUsername" placeholder="Username"
aria-describedby="inputGroupPrepend" value="<?php echo isset($middlename) ? $middlename : '' ?>" required>
<div class="invalid-feedback">
champ requis
</div>
</div>
</div>
<div class="form-group mb-3">
<label class="form-label" for="validationCustom04">Téléphone</label>
<input type="text" class="form-control" name="contact" id="validationCustom04" placeholder="Téléphone" required value="<?php echo isset($contact) ? $contact : '' ?>">
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<label class="form-label" for="validationCustom05">Addresse</label>
<input type="text" class="form-control" name="address" id="validationCustom05" placeholder="Adresse" value="<?php echo isset($address) ? $address : '' ?>" required>
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<img src="google-logo.png" alt="HTML tutorial"style="max-height:100px;">
<input type="text" class="form-control" name="grl" id="validationCustom06" placeholder="Google Link" value="<?php echo isset($grl) ? $grl : '' ?>" required>
<small><i>veuillez saisir le lien avec "https://" </i></small>
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<img src="Facebook-Logo.png" alt="HTML tutorial" style="max-height:100px;">
<input type="text" class="form-control" name="frl" id="validationCustom07" placeholder="Facebook Link" value="<?php echo isset($frl) ? $frl : '' ?>" required>
<small><i>veuillez saisir le lien avec "https://" </i></small>
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<img src="Tripadvisor-Logo.png" alt="HTML tutorial" style="max-height:100px;">
<input type="text" class="form-control" name="tpv" id="validationCustom07" placeholder="TripAdvisor Link" value="<?php echo isset($tpv) ? $tpv : '' ?>" required>
<small><i>veuillez saisir le lien avec "https://" </i></small>
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<label class="form-label" for="validationCustom05">E-mail</label>
<input type="text" class="form-control" name="email" id="validationCustom08" placeholder="Enter Email Address..." required value="<?php echo isset($email) ? $email : '' ?>">
<div class="invalid-feedback">
champ requis
</div>
</div>
<div class="form-group mb-3">
<label class="control-label">Mot de passe</label>
<input type="text" class="form-control form-control-sm" value = "<?php echo $editpass ?>" name="password" <?php echo isset($id) ? "":'required' ?>>
<small><i><?php echo isset($id) ? "Laissez ce champ vide si vous ne souhaitez pas modifier le mot de passe":'' ?></i></small>
</div>
<div class="form-group mb-3" hidden>
<label class="control-label">Mot de passe</label>
<input type="password" class="form-control form-control-sm" value = "" name="editpass">
</div>
<div class="form-group mb-3">
<label class="label control-label">Confirmer Mot de passe</label>
<input type="text" class="form-control form-control-sm" value = "<?php echo $editpass ?>" name="cpass" <?php echo isset($id) ? 'required' : '' ?>>
<small id="pass_match" data-status=''></small>
</div>
<hr>
<div class="col-lg-12 text-right justify-content-center d-flex">
<button class="btn btn-primary mr-2" name="submit" value="Upload">Sauvegarder</button>
<button class="btn btn-secondary" type="button" onclick="location.href = 'index.php?page=user_list'">Annuler</button>
</div>
</form>
</div>
</div>
</div>
<script src="pj/assets/js/vendor.min.js"></script>
<script src="pj/assets/js/app.min.js"></script>
<script>
$('[name="password"],[name="cpass"]').keyup(function(){
var pass = $('[name="password"]').val()
var cpass = $('[name="cpass"]').val()
if(cpass == '' ||pass == ''){
$('#pass_match').attr('data-status','')
}else{
if(cpass == pass){
$('#pass_match').attr('data-status','1').html('<i class="text-success">Password Matched.</i>')
}else{
$('#pass_match').attr('data-status','2').html('<i class="text-danger">Password does not match.</i>')
}
}
})
function displayImg(input,_this) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#cimg').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$('#manage_user').submit(function(e){
e.preventDefault()
$('input').removeClass("border-danger")
start_load()
$('#msg').html('')
$.ajax({
url:'ajax.php?action=save_edition',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success:function(resp){
if(resp == 1){
alert_toast('profile à jour',"success");
setTimeout(function(){
location.replace('index.php?page=home')
},750)
}else if(resp == 2){
$('#msg').html("<div class='alert alert-danger'>L'e-mail existe déjà.</div>");
$('[name="email"]').addClass("border-danger")
end_load()
}
}
})
})
</script>