-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_user_code.php
80 lines (60 loc) · 2.3 KB
/
edit_user_code.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
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
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
<?php
require_once('connection.php');
$user_id=$_POST['user_id'];
$username=$_POST['username'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$uploaded = false;
$filepath_image = '';
if(isset($_FILES)){
$filetmp= $_FILES["user_image"]["tmp_name"];
$filename_image= $_FILES["user_image"]["name"];
$filetype= $_FILES["user_image"]["type"];
$filepath_image= "user_images/".$filename_image;
$imgsize=filesize($filetmp); //to get image size
if(!move_uploaded_file($filetmp,$filepath_image)){
$uploaded = false;
echo '<script>
setTimeout(function () {
swal({
title: "Error!",
text: "Error while uploading File.",
type: "error",
confirmButtonText: "OK"
},
function(isConfirm){
if (isConfirm) {
window.location.href = "edit_post.php";
}
}); }, 1000);
</script>';
//return false;
}else{
$uploaded = true;
}
}
$UpdateData="UPDATE `user_info` SET `name`='$username',`email`='$email',`contact_no`='$phone',`password`='$address' ";
if( $uploaded == true ){
$UpdateData .= " ,`user_image`='$filepath_image' WHERE `user_id` = $user_id";
}else{
$UpdateData .= " WHERE `user_id` = $user_id";
}
//var_dump($UpdateData);die;
$resultData=mysqli_query($conn,$UpdateData);
if($resultData)
{
echo '<script>
alert("Success");
window.location.href = "index.php";
</script>';
} else {
echo '<script>
alert("Fail to Update!");
window.location.href = "index.php";
</script>';
}
?>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>