-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile.php
executable file
·146 lines (129 loc) · 4.05 KB
/
profile.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
<?php
include 'includes/session.php';
include 'includes/dbConnect.php';
?>
<!DOCTYPE html>
<html>
<?php
include 'includes/header.php';
?>
<body>
<?php
include 'includes/navigationBar.php';
?>
<?php
if (!isset($_SESSION['user_id'])){
header("Location: error.php");
exit;
}
?>
<div class="section" style="background-image: url(assets/images/try.jpg);">
<div class="container overlay-profile-box">
<div class="row">
<div class="col-md-12">
<h1 class="text-center" style="color:#000;">
<?php
echo $name;
echo "'s ";
?>
Profile
</h1>
</div>
</div>
<?php
if (isset($_GET['errorCode'])){
$errorCode = mysqli_real_escape_string($connection, $_GET['errorCode']);
echo '<div class="row">';
echo '<div class="col-md-12">';
echo '<font color="#ff0000">';
echo '<ul>';
if (strpos($errorCode, 'n') !== false){
echo '<li>Your name can not be less than 2 characters long.</li>';
}
else if (strpos($errorCode, 'g') !== false){
echo '<li>Gender can only be M (male) or F (female).</li>';
}
echo '</ul>';
echo '</font>';
echo '</div>';
echo '</div>';
}
?>
<div class="row">
<div class="col-md-12">
<?php
$query = "SELECT * FROM users WHERE user_id='$user_id'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
?>
<form role="form" method="post" class="profile-form" action="updateProfile.php" style="float: none;margin-left: auto;margin-right: auto;">
<h4>Profile picture:</h4>
<?php
if (isset($fb_id)){
echo "<img src='http://graph.facebook.com/$fb_id/picture?type=large&width=200&height=200'>";
}
else {
echo "<img src='assets/images/empty-profile-picture.jpg' width=200 height=200>";
}
?>
<br>
<hr>
<h4>Full name:</h4>
<b>
<input type="text" name="full_name" size="32" style="border: 0" value="<?php echo $row['full_name']; ?>" readonly required />
<input name="Edit" class="custom-btn5 hvr-bob btn-default" type="button" value="Edit">
</b>
<br>
<hr>
<h4>Email:</h4>
<b>
<input type="text" name="email" size="32" style="border: 0; background: none;" value="<?php echo $row['email']; ?>" disabled />
</b>
<br>
<hr>
<h4>Birth date:</h4>
<b>
<input type="text" name="birth_date" size="32" style="border: 0; background: none;" value="<?php if (isset($row['birth_date'])) echo date_format(date_create($row['birth_date']), 'jS F Y'); ?>" disabled />
</b>
<br>
<hr>
<h4>Gender:</h4>
<b>
<input type="text" name="gender" size="32" style="border: 0" value="<?php echo $row['gender']; ?>" readonly required />
<input name="Edit" class="custom-btn5 hvr-bob btn-default" type="button" value="Edit">
</b>
<br>
<hr>
<h4>Location:</h4>
<b>
<input type="text" name="location" size="32" style="border: 0" value="<?php echo $row['location']; ?>" readonly required />
<input name="Edit" class="custom-btn5 hvr-bob btn-default" type="button" value="Edit">
</b>
<br>
<hr>
<h4>Last login:</h4>
<b>
<input type="text" name="last_login" size="32" style="border: 0; background: none;" value="<?php echo $row['last_login']; ?>" disabled />
</b>
<br>
<script type="text/javascript">
$('[name="Edit"]').on('click', function() {
var prev = $(this).prev('input'),
ro = prev.prop('readonly');
prev.prop('readonly', !ro).focus();
$(this).val(ro ? 'Save' : 'Edit');
if (!ro){
$(".profile-form").submit();
}
});
</script>
</form>
</div>
</div>
</div>
</div>
<?php
include 'includes/footer.php';
?>
</body>
</html>