-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
61 lines (53 loc) · 1.95 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
<?php
require 'includes/header.php';
require 'includes/dbhandler.php';
?>
<main>
<link rel="stylesheet" href="css/profile.css">
<script>
function triggered() {
document.querySelector("#prof-image").click();
}
function preview(e) {
if (e.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
document.querySelector('#prof-display').setAttribute('src', e.target.result);
}
reader.readAsDataURL(e.files[0]);
}
}
</script>
<?php
if(isset($_SESSION['uid'])){
//username after login
$prof_user = $_SESSION['uname'];
$sqlpro = "SELECT * FROM profiles WHERE uname='$prof_user';";
$res = mysqli_query($conn, $sqlpro);
$row = mysqli_fetch_array($res);
$photo = $row['profpic'];
?>
<div class="h-50 center-me text-center">
<div class="my-auto">
<form action="includes/upload-helper.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<img src="<?php echo $photo;?>" alt="profile pic" onclick="triggered();" id="prof-display">
<label for="prof-image" id="uname-style"><?php echo $prof_user?></label>
<input type="file" name="prof-image" id="prof-image" onchange="preview(this)" class="form-control"
style="display: none;">
</div>
<div class="form-group">
<textarea name="bio" id="bio" cols="30" rows="10" placeholder="Bio..."
style="text-align: center"></textarea>
</div>
<div class="form-group">
<button type="submit" name="prof-submit"
class="btn btn-outline-success btn-lg btn-block">upload</button>
</div>
</form>
</div>
</div>
<?php
}
?>
</main>