-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_home.php
executable file
·170 lines (129 loc) · 4.78 KB
/
edit_home.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
include('config.php');
include('masterpage/dashboard_header.php');
include('masterpage/dashboard_navbar.php');
include('masterpage/dashboard_sidebar.php');
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">Dashboard</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">About Us</li>
</ol>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<?php
$fetch = mysqli_query($config,"SELECT * FROM user_info WHERE username ='{$_SESSION['loggedInUser']}'");
while($row = mysqli_fetch_assoc($fetch))
{
$adphon = $row['phone_number'];
$admail = $row['email'];
$adress = $row['address'];
$uname = $row['username'];
$fname = $row['fullname'];
$userimg = $row['user_image'];
$instagram = $row['insta_id'];
$facebook = $row['fb_id'];
}
?>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Quick Example</h3>
</div>
<form method="post" enctype="multipart/form-data">
<div class="card-body">
<div class="form-group">
<label for="exampleInputNumber">Phone Number</label>
<input type="number" class="form-control" name="uphon" id="Pnumber" value="<?php echo $adphon; ?>">
</div>
<div class="form-group">
<label for="Address">Email</label>
<input type="text" class="form-control" name="umail" id="mail" value="<?php echo $admail; ?>">
</div>
<div class="form-group">
<label for="Address">Fullname</label>
<input type="text" class="form-control" name="fname" id="fname" value="<?php echo $fname; ?>">
</div>
<div class="form-group">
<label for="Address">Address</label>
<input type="text" class="form-control" name="uaddes" id="Address" value="<?php echo $adress; ?>">
</div>
<div class="form-group">
<label for="Address">username</label>
<input type="username" class="form-control" name="user" id="username" value="<?php echo $uname; ?>" readonly="">
</div>
<div class="form-group">
<label for="Address">Instagram profile</label>
<input type="username" class="form-control" name="instagram" id="profile" value="<?php echo $instagram; ?>" >
</div>
<div class="form-group">
<label for="Address">Facebook Profile</label>
<input type="username" class="form-control" name="facebook" id="profile" value="<?php echo $facebook; ?>" >
</div>
<div class="form-group">
<label for="image">User Image</label>
<input type="file" accept="jpg,png,jpeg" class="form-control" name="userimg" id="userpimg" value="<?php echo $userimg; ?>">
</div>
<button type="submit" name="submit" class="btn btn-primary">Update Profile</button>
</div>
</form>
</div>
<?php
if(isset($_POST['submit']))
{
$pone = $_POST['uphon'];
$mail = $_POST['umail'];
$uradd = $_POST['uaddes'];
$uname = $_POST['user'];
$fullname = $_POST['fname'];
$userimg = $_POST['user_image'];
$instagram = $_POST['instagram'];
$facebook = $_POST['facebook'];
// image configuration starts here
$base_url = "http://localhost/vCard/";
$targetFolder = "modules/upload_userpic/";
$orgimageName = $_FILES['userimg']['name'];
$tempPicName = $_FILES['userimg']['tmp_name'];
$completeImageName = $base_url.$targetFolder.$orgimageName;
// $sql = "UPDATE user_info SET phone_number='$pone',email='$mail',address='$uradd',fullname = '$fullname',userpic = '$userimg' WHERE username ='{$_SESSION['loggedInUser']}'";
if(!empty($orgimageName))
{
mysqli_query($config,"UPDATE user_info SET phone_number='$pone',email='$mail',address='$uradd',fullname = '$fullname',insta_id='$instagram',fb_id = '$facebook',user_avatar = '$completeImageName' WHERE username ='{$_SESSION['loggedInUser']}'");
move_uploaded_file($tempPicName, $targetFolder.$orgimageName);
echo "<script>alert('Data & Profile Picture Updated Successfully');window.location.href='edit_home.php'</script>";
}
elseif(empty($orgimageName))
{
mysqli_query($config,"UPDATE user_info SET phone_number='$pone',email='$mail',address='$uradd',fullname = '$fullname',insta_id='$instagram',fb_id = '$facebook' WHERE username ='{$_SESSION['loggedInUser']}'");
echo "<script>alert('Data Updated Successfully');window.location.href='edit_home.php'</script>";
}
else
{
echo "<script>alert('No Data Changed')</script>";
}
}
?>
</div>
</div>
</div>
</div>
</section>
</div>
<?php
include('masterpage/dashboard_footer.php');
?>