-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofilepic.php
More file actions
69 lines (56 loc) · 1.47 KB
/
profilepic.php
File metadata and controls
69 lines (56 loc) · 1.47 KB
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
<?php
session_start();
if($_SESSION["me"]==""){
?>
<script>
window.location="login.php";
</script>
<?php
}
?>
<?php
$q=$_GET["user"];
?>
<?php
$link=mysqli_connect("localhost","root","");
mysqli_select_db($link,"chatapp");
?>
<?php
if(isset($_POST["submit"])){
move_uploaded_file($_FILES["file"]["tmp_name"],'profilepicture/'.$_FILES["file"]["name"]);
$res=mysqli_query($link,'UPDATE profile_pic SET profilepic="'.$_FILES["file"]["name"].'" WHERE id="'. $q.'"');
}
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chitchat</title>
<link rel="icon" type="img/png" href="css/messages.png" sizes="96x96"></link>
<link rel="stylesheet" href="css1/profilepic.css"></link>
</head>
<body style="background-color: #000000;">
<header><span style="float: left">
Profile Picture</span>
<span style="padding-left: 680px;float: right;">
<form method="post" action="" enctype="multipart/form-data" >
<input type="file" name="file" ></input>
<input type="submit" value="Change DP" name="submit"></input>
</form>
</span>
</form>
</header>
<section>
<?php
$result=mysqli_query($link,'SELECT profilepic FROM profile_pic WHERE id="'. $q.'"');
while($row=mysqli_fetch_assoc($result)){
if ($row["profilepic"] == "" ){
echo '<img class="img-sqr" src="profilepicture/default.jpg" alt="default DP" >';
}else{
echo "<img class='img-sqr' src='profilepicture/".$row['profilepic']."' alt='DP' >";
}
}
?>
</section>
</body>
</html>