-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmingprofileprocess.php
More file actions
70 lines (49 loc) · 2.15 KB
/
admingprofileprocess.php
File metadata and controls
70 lines (49 loc) · 2.15 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
<?php
session_start();
include "db\connections.php";
$email = $_SESSION["admin"]["email"];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$ad1 = $_POST["ad1"];
$ad2 = $_POST["ad2"];
$user_rs = Database::search("SELECT * FROM `aplyadmins` WHERE `email`='" . $email . "'");
if(empty($ad1)){
echo ("please enter your address.");
}else if(empty($ad2)){
echo ("please enter your address");
}else
if ($user_rs->num_rows == 1) {
Database::iud("UPDATE `aplyadmins` SET `fname`='" . $fname . "',`lname`='" . $lname . "',`address_line1`='" . $ad1 . "',`address_line2`='" . $ad2 . "' WHERE
`email`='" . $email . "'");
if (sizeof($_FILES) == 1) {
$image = $_FILES["i"];
$image_extension = $image["type"];
$allowed_image_extensions = array("image/jpeg", "image/png", "image/svg+xml");
if (in_array($image_extension, $allowed_image_extensions)) {
$new_img_extension;
if ($image_extension == "image/jpeg") {
$new_img_extension = ".jpeg";
} else if ($image_extension == "image/png") {
$new_img_extension = ".png";
} else if ($image_extension == "image/svg+xml") {
$new_img_extension = ".svg";
}
$file_name = "navod" . $email . "_" . uniqid() . $new_img_extension;
move_uploaded_file($image["tmp_name"], $file_name);
$profile_img_rs = Database::search("SELECT * FROM `aplyadmins` WHERE `email`='" . $email . "'");
if ($profile_img_rs->num_rows == 1) {
Database::iud("UPDATE `aplyadmins` SET `profile_image`='" . $file_name . "' WHERE `email`='" . $email . "'");
echo ("Updated");
} else {
Database::iud("INSERT INTO `aplyadmins`(`profile_image`,`email`) VALUES ('" . $file_name . "','" . $email . "')");
echo ("Saved");
}
}
} else if (sizeof($_FILES) == 0) {
echo ("updated your profile.");
} else {
echo ("You must select only 01 profile image.");
}
} else {
echo ("Invalid user.");
}