forked from Webscorpion1/Snapshot
/
profile_edit.php
121 lines (103 loc) · 4.42 KB
/
profile_edit.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
<?php
include_once("classes/User.class.php");
User::checklogin();
if (!empty ($_POST)) {
$file = $_FILES['photo'];
$fileName = $_FILES['photo']['name'];
$fileTmpName = $_FILES['photo']['tmp_name'];
$fileSize = $_FILES['photo']['size'];
$fileError = $_FILES['photo']['error'];
$fileType = $_FILES['photo']['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg', 'jpeg', 'png');
if (in_array($fileActualExt, $allowed)) {
if ($fileError === 0) {
if ($fileSize < 10000) {
$fileNameNew = uniqid('', true) . "." . $fileActualExt;
$fileDestination = 'uploads/' . $fileNameNew;
print_r($fileDestination);
move_uploaded_file($fileTmpName, $fileDestination);
$user = new User();
if ($_POST['confirmation_pw'] == $user->getPassword()) {
}
$user->setEmail(strip_tags($_POST['change_email']));
$user->setAvatar(strip_tags($fileDestination));
$user->setDescr(strip_tags($_POST['bio']));
$user->setPassword(strip_tags($_POST['change_password']));
$user->editprofile(strip_tags($_GET['user']));
header('Location: index.php');
}
}
}
}
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Account - Snapshot</title>
<meta name="description" content="snapshot" />
<meta name="keywords" content="snapshot, imd" />
<meta name="author" content="Lucas Debelder, Jasmina Dahou, Sander Verbesselt, Frederik Delaet" />
<link href="https://fonts.googleapis.com/css?family=Montserrat:600,800|Open+Sans" rel="stylesheet">
<script defer src="https://use.fontawesome.com/releases/v5.0.4/js/all.js"></script>
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/master.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">
<meta property="og:url" content="">
<meta property="og:type" content=""/>
<meta property="og:title" content=""/>
<meta property="og:description" content=""/>
<meta property="og:image" content=""/>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="">
<meta name="twitter:creator" content="">
<meta name="twitter:title" content="">
<meta name="twitter:description" content=" ">
<meta name="twitter:image" content="">
</head>
<nav>
<ul>
<div class="logo">
<li><img src="media/frontend/logo.svg" alt="Logo" ></li>
</div>
<div class="links">
<li><a href="index.php">Home</a></li>
<li><a href="friendposts.php">Friend's posts</a></li>
<li><a href="addpost.php">Add post</a></li>
<li><a href="profile.php?user=<?php echo $_SESSION['userid']; ?>">Profile</a></li>
<li><a href="logout.php">Log out</a></li>
</div>
</ul>
</nav>
<form action="" method="post" enctype="multipart/form-data">
<h1 form__title>Update account</h1>
<div>
<label for="photo">UPDATE PROFILE PICTURE</label><br/>
<input class="form__input" type="file" class="fileToUpload" name="photo" placeholder="">
</div>
<div>
<label for="bio">UPDATE/EDIT BIO</label><br/>
<input class="form__input" type="text" id="bio" name="bio" placeholder="">
</div>
<div>
<label for="change_email">CHANGE EMAIL</label><br/>
<input class="form__input" type="email" id="change_email" name="change_email" placeholder="">
</div>
<div>
<label for="change_password">CHANGE PASSWORD</label><br/>
<input class="form__input" type="password" id="change_password" name="change_password" placeholder="">
</div>
<div>
<label for="confirmation_pw">TYPE IN THE CURRENT PASSWORD TO VERIFY</label><br/>
<input class="form__input" style="background-color: rgba(247, 129, 34, 0.1);" type="password" id="confirmation_pw" name="confirmation_pw" placeholder="">
</div>
<div>
<input class="form__input" type="submit" name="submit" value="SAVE PROFILE" class="btn_style">
</div>
</form>
</body>
</html>