-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateprofile.php
executable file
·189 lines (185 loc) · 7.49 KB
/
updateprofile.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
<!DOCTYPE html>
<?php
include 'connection.php';
session_start();
if (!(isset($_SESSION['id']))) {
header('location:index.php');
}
$id=$_SESSION['id'];
$query=mysqli_query($db,"SELECT * FROM users where user_id='$id'")or die(mysqli_error($db));
$rows=mysqli_fetch_array($query);
?>
<html lang="en-US">
<?php include 'header.php' ?>
<div class="div-profile">
<p class="impact">Please Fill-out All Fields</p>
<form method="post" action="#" >
<div class="div-profileUpdate">
<label>Full Name</label>
<input type="text" class="form-control" name="fname" style="width:20em;" placeholder="Enter your Fullname" value="<?php echo $rows['full_name']; ?>" readonly />
</div>
<div class="div-profileUpdate">
<label>Gender</label>
<input type="text" class="form-control" name="gender" style="width:20em;" placeholder="Enter your Gender" required value="<?php echo $rows['gender']; ?>" readonly/>
</div>
<div class="div-profileUpdate">
<label>Age</label>
<input type="number" class="form-control" name="age" style="width:20em;" placeholder="Enter your Age" value="<?php echo $rows['age']; ?>">
</div>
<div class="div-profileUpdate">
<label>Country</label>
<input type="text" class="form-control" name="country" style="width:20em;" required placeholder="Enter your Country" value="<?php echo $rows['country']; ?>" required></textarea>
</div>
<div class="div-profileUpdate">
<label>Username</label>
<input type="text" class="form-control" name="uname" style="width:20em;" placeholder="Edit your Username" value="<?php echo $rows['username']; ?>" required/>
</div>
<div>
<center>
<input type="submit" name="submit" class="btn btn-primary" style="width:20em; margin:0;"><br><br>
</center>
</div>
</form>
</div>
<div class="div-profile">
<p class="impact">Please Fill-out All Fields</p>
<div class="small">
<form method="post" action="" enctype="multipart/form-data">
<div class="div-profileUpdate">
<label>Upload Picture</label>
<input type='file' class="form-control" name="profilepic"/>
</div>
<div>
<center>
<button type="submit" name="upload" class="btn btn-primary" style="width:10em; margin:0;">UPLOAD</button><br><br>
</center>
</div>
</form>
</div>
<div class="small">
<form method="post" action="#" >
<div class="div-profileUpdate">
<label>Facebook</label>
<input type="text" class="form-control" name="fb" placeholder="Enter URL" value="<?php echo $rows['facebook']; ?>" />
</div>
<div>
<center>
<button type="submit" name="flink" class="btn btn-primary" style="width:10em; margin:0;">CONNECT</button><br><br>
</center>
</div>
</form>
</div>
<div class="small">
<form method="post" action="#" >
<div class="div-profileUpdate">
<label>Twitter</label>
<input type="text" class="form-control" name="twitter" placeholder="Enter URL" value="<?php echo $rows['twitter']; ?>" />
</div>
<div>
<center>
<button type="submit" name="tlink" class="btn btn-primary" style="width:10em; margin:0;">CONNECT</button><br><br>
</center>
</div>
</form>
</div>
<div class="small">
<form method="post" action="#" >
<div class="div-profileUpdate">
<label>Other</label>
<input type="text" class="form-control" name="other" placeholder="Enter URL" value="<?php echo $rows['others']; ?>" />
</div>
<div>
<center>
<button type="submit" name="olink" class="btn btn-primary" style="width:10em; margin:0;">CONNECT</button><br><br>
</center>
</div>
</form>
</div>
<center>
<p class="impact"><a href="logout.php">Log out</a></p>
</center>
</div>
</html>
<?php
if(isset($_POST['submit'])){
$fullname = $_POST['fname'];
$username = $_POST['uname'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$country = $_POST['country'];
$query = "UPDATE users SET age = $age, country = '$country', username='$username'
WHERE user_id = '$id'";
$result = mysqli_query($db, $query) or die(mysqli_error($db));
?>
<script type="text/javascript">
alert("Update Successfull.");
window.location = "profile.php";
</script>
<?php
}
?>
<?php
if(isset($_POST['flink'])){
$url = $_POST['fb'];
$query = "UPDATE users SET facebook ='$url'
WHERE user_id = '$id'";
$result = mysqli_query($db, $query) or die(mysqli_error($db));
?>
<script type="text/javascript">
alert("Update Successfull.");
window.location = "updateprofile.php";
</script>
<?php
}
?>
<?php
if(isset($_POST['tlink'])){
$url = $_POST['twitter'];
$query = "UPDATE users SET twitter ='$url'
WHERE user_id = '$id'";
$result = mysqli_query($db, $query) or die(mysqli_error($db));
?>
<script type="text/javascript">
alert("Update Successfull.");
window.location = "updateprofile.php";
</script>
<?php
}
?>
<?php
if(isset($_POST['olink'])){
$url = $_POST['other'];
$query = "UPDATE users SET others = '$url'
WHERE user_id = '$id'";
$result = mysqli_query($db, $query) or die(mysqli_error($db));
?>
<script type="text/javascript">
alert("Update Successfull.");
window.location = "updateprofile.php";
</script>
<?php
}
?>
<?php
// If upload button is clicked ...
if (isset($_POST['upload'])) {
$filename = $_FILES["profilepic"]["name"];
$tempname = $_FILES["profilepic"]["tmp_name"];
$folder = "upload/image/".$filename;
// Get all the submitted data from the form
$sql= "UPDATE users SET dp='$filename'
WHERE user_id = '$id'";
// Execute query
mysqli_query($db, $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";
}
}
$result = mysqli_query($db, "SELECT * FROM users");
?>