-
Notifications
You must be signed in to change notification settings - Fork 1
/
updateuserdata.php
56 lines (37 loc) · 1.21 KB
/
updateuserdata.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
<?php
session_start();
include("config.php");
function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
}
$usname=$_POST['uname'];
$uspass=$_POST['upass'];
$usem=$_POST['uemailid'];
$usaddtopic=$_POST['add_topic'];
$usdeltopic=$_POST['delete_topic'];
if (!empty($_FILES["uploadedimage"]["name"])) {
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext= GetImageExtension($imgtype);
$imagename=date("d-m-Y")."-".time().$ext;
$target_path = "images/".$imagename;
$uid=$_SESSION["user_id"];
if(move_uploaded_file($temp_name, $target_path)) {
$res=mysqli_query($db,"UPDATE `users` SET `name`='$usname',`pass`='$uspass',`emailid`='$usem',`image_path`='".$target_path."',`lastupdated`='".date("Y-m-d")."' WHERE user_id='$uid'";
mysqli_query($db,$query_upload);
}
}
else{
exit("Error While uploading image on the server");
}
?>