-
Notifications
You must be signed in to change notification settings - Fork 45
/
profilechange.php
53 lines (49 loc) · 1.47 KB
/
profilechange.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
<?php
session_start();
if(!isset($_SESSION['useremail'])){
echo "<div align='center' style='font-family : calibri; color:white; background:#D20D0D; padding:15px;'>Access Denied</div>";
}
else{
include('includes/conn.php');
$q = "SELECT * FROM doctor WHERE email ='".$_SESSION['useremail']."'";
$r = mysqli_query($con,$q);
while($row = mysqli_fetch_assoc($r)){
$type = $row['type'];
}
if(@$type=="doc"){
echo "<div align='center' style='font-family : calibri; color:white; background:#D20D0D; padding:15px;'>Access Denied</div>";
}
else{
$email = $_SESSION['useremail'];
$mypic = $_FILES['newupload']['name'];
$type = $_FILES['newupload']['type'];
$temp = $_FILES['newupload']['tmp_name'];
include('includes/conn.php');
$query = "SELECT * FROM patient WHERE email ='".$email."'";
$rec = mysqli_query($con,$query);
while($row = mysqli_fetch_assoc($rec)){
$adhar = $row['adharno'];
}
if(($type=="image/jpeg") || ($type=="image/jpg") || ($type=="image/png")){
$dir = "patient/".$adhar."/img";
$files = 0;
$handle = opendir($dir);
while(($file = readdir($handle))!=FALSE){
if($file!="."&&$file!=".."&&$file !="Thumbs.db"){
unlink($dir."/".$file);
$files++;
}
}
closedir($handle);
sleep(1);
move_uploaded_file($temp,"patient/$adhar/img/$mypic");
echo '<script type="text/javascript">';
echo 'alert("Your Profile Picture has been updated successfully");';
echo 'window.location.href = "patient.php#profile";';
echo '</script>';
}else{
echo "Invalid Image";
}
}
}
?>