-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheditprofile.php
203 lines (165 loc) · 6.67 KB
/
editprofile.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
require_once 'core/init.php';
require_once 'functions/functions.php';
ini_set("display_errors", 1);
error_reporting(E_ALL);
$db = Database::getInstance();
$id = "";
$fname = "";
$lname = "";
$regno = "";
$email = "";
$gender = "";
$category = "";
$st = "";
$tel = "";
$bounties = "";
$website = "";
$bio = "";
$created = "";
$address = "";
if (isset($_GET['id']) && !empty($_GET['id'])) {
$userid = $_GET['id'];
$where = array("id", "=", $userid);
$data = $db->get("users", $where)->results();
// var_dump($data);
foreach ($data as $value) {
$user = array(
"id" => ($value->id),
"name" => ($value->name),
"email" => ($value->email),
"gender" => ($value->gender),
"regno" => ($value->reg_no),
"category" => ($value->category),
"status" => ($value->status),
"tel" => ($value->tel),
"bounties" => ($value->bounties),
"website" => ($value->website),
"created" => ($value->created),
"bio" => ($value->bio),
"address" => ($value->address)
);
extract($user);
//get status as lable
$st = getStatus($status);
//Set Gender Strings
if($gender){
switch ($gender) {
case 'M':
$gender = 'Male';
break;
case 'F':
$gender = 'Female';
break;
}
}
//split fname and lname
if($name){
$name = explode(" ", $name);
$fname = $name[0];
$lname = $name[1];
}
}
}
if(isset($_POST['submit-changes'])){
$id = $_GET['id'];
$name = "\"".Input::get("fname")." ".Input::get("lname")."\"";
$tel = "\"".Input::get("tel")."\"";
$email = "\"".Input::get("email")."\"";
$bio = "\"".Input::get("bio")."\"";
$where_email = Input::get("email");
$fields = array('name' => $name,
'email' => $email,
'bio' => $bio,
'tel' => $tel);
if($db->update('users', $where_email, $fields)){
//To be Implemented on Ajax
header('location: editprofile.php?id='.$id);
}
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SwahiliPotHub | Edit</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/custom.css">
</head>
<nav class="navbar navbar-default"></nav>
<div class="container target">
<div class="row">
<form action="" method="POST">
<div class="col-sm-3">
<!--left col-->
<ul class="list-group panel-default">
<li class="list-group-item text-muted panel-heading" contenteditable="false">Profile</li>
<li class="list-group-item "><strong class="">Reg. NO:</strong><span class="pull-right"><?php echo $regno; ?></span> </li>
<li class="list-group-item "><strong class="">Sex:</strong><span class="pull-right"><?php echo $gender; ?></span> </li>
<li class="list-group-item "><strong class="">Joined:</strong> <span class="pull-right"><?php echo $created; ?></span> </li>
<li class="list-group-item "><strong class="">Status:</strong><span class="pull-right"> <?php echo $st; ?></span> </li>
</ul>
<div class="panel panel-default">
<div class="panel-heading">Community</div>
<div class="panel-body">
<label class="pull-left">Current Bounties:</label>
<span type="number" name="bounties" class="pull-right" ><?php echo $bounties; ?> </span>
<!-- Input to Increase the bonga points -->
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Social Media</div>
<div class="panel-body">
</div>
</div>
</div>
<!--/col-3-->
<div class="col-sm-9" contenteditable="false" style="">
<div class="panel panel-default">
<div class="panel-heading">User Details</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<label>First Name </label>
<input class="form-control" type="text" name="fname" required value=<?php echo $fname; ?>>
<label>Email Address </label>
<input class="form-control" type="email" name="email" required value=<?php echo $email; ?>>
</div>
<div class="col-md-6">
<label>Last Name </label>
<input class="form-control" type="text" name="lname" required value=<?php echo $lname; ?> >
<label>Phone Number</label>
<input class="form-control" type="tel" name="tel" required value=<?php echo $tel; ?>>
</div>
</div>
</div>
</div>
<div class="panel panel-default target">
<div class="panel-heading" contenteditable="false">Bio</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<textarea class="form-control" name="bio" style="height:150px;" ><?php echo $bio; ?></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="pull-right">
<button type="reset" class="btn btn-danger">Cancel</button>
<button type="submit" name="submit-changes" class="btn btn-primary">Save Details</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<footer id="footer">
</footer>
</div>