-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveChangesProcess.php
More file actions
88 lines (54 loc) · 2.33 KB
/
saveChangesProcess.php
File metadata and controls
88 lines (54 loc) · 2.33 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
session_start();
include "connection.php";
$email = $_SESSION["ad"]["email"];
$fname = $_POST["f"];
$lname = $_POST["l"];
if(empty($fname)){
echo("Please enter your first name");
}else if(empty($lname)){
echo("Please enter your last name");
}else{
$admin_rs = Database::search("SELECT * FROM `admin` WHERE `email` = '".$email."' ");
$admin_num = $admin_rs->num_rows;
if($admin_num == 1){
Database::iud("UPDATE `admin` SET `fname` = '".$fname."' , `lname` = '".$lname."' WHERE `email` = '".$email."' ");
if(sizeof($_FILES) == 1){
$image = $_FILES["i"];
$image_extention = $image["type"];
$allowed_img_extention = array("image/jpg" , "image/png" , "image/jpeg" , "image/svg+xml");
if(in_array($image_extention, $allowed_img_extention)){
$new_img_extention;
if($image_extention == "image/jpg"){
$new_img_extention = ".jpg";
}else if($image_extention == "image/png"){
$new_img_extention = ".png";
}else if($image_extention == "image/jpeg"){
$new_img_extention = ".jpeg";
}else if($image_extention == "image/svg+xml"){
$new_img_extention = ".svg";
}
$file_path = "img//profile_images//".$fname."_".uniqid().$new_img_extention;
move_uploaded_file($image["tmp_name"],$file_path);
$image_rs = Database::search("SELECT * FROM `admin_profile` WHERE `admin_email` = '".$email."' ");
$image_num = $image_rs->num_rows;
if($image_num == 1){
Database::iud("UPDATE `admin_profile` SET `img_path` = '".$file_path."' WHERE `admin_email` = '".$email."' ");
// echo("updated");
}else{
Database::iud("INSERT INTO `admin_profile` (`img_path` , `admin_email`) VALUES ('".$file_path."' , '".$email."')");
// echo("saved");
}
}else{
echo("invalid image type");
}
}
// }else{
// echo("Invalid image count");
// }
echo("success");
}else{
echo("Invalid user");
}
}
?>