forked from Infinito-IIT-Patna/Infinito2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editProfile.php
227 lines (202 loc) · 9.4 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
include "connect.php";
$infid = $_GET['infid'];
include "editProfileHandle.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Edit Profile</title>
<?php
require('./templates/header.php');
?>
<link rel="stylesheet" href="css/profile.css">
</head>
<body>
<!-- Navigation bar -->
<div class="bac" style="background: #172134; position:fixed; width:100%; top:0px; z-index:100; margin-bottom:100px;">
<div class="container" style="padding:10px 0">
<a href="index.php" class="logo float-left tran4s"><img src="images/logo/logo.png" alt="Logo" style="border-radius:100%; height:56px; width:56px;" /></a>
<!-- ========================= Theme Feature Page Menu ======================= -->
<nav class="navbar float-right theme-main-menu one-page-menu">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false" style="margin-top:8px;">
<span class="sr-only">Toggle navigation</span>
Menu
<i class="fa fa-bars" aria-hidden="true"></i>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse-1" style="margin-top:10px">
<ul class="nav navbar-nav">
<li><a href="./index.php">Home</a></li>
<li><a href="./events.php">Events</a></li>
<li><a href="./team.php">Team</a></li>
<li><a href="./gallery.php">Gallery</a></li>
<li><a href="./registration.php">Register</a></li>
<li class="active"><a href="./profile.php">Profile</a>
<li>
<li><a href="./logout.php">Logout</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</nav>
<!-- /.theme-feature-menu -->
</div>
</div>
<?php
if ($showerror == true) {
echo '<div class="container">
<div class="alert alert-success alert-dismissible show" role="alert" style="position:relative; top:75px; width:100%; color:red; background: #ff000020;" >
<strong> ' . $showerror . ' </strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>';
}
?>
<!-- Details -->
<div class="profile_personal">
<div class="pro_btn">
<a href="./profile.php">
<button>Personal Details</button>
</a>
<a href="./editProfile.php">
<button class="active_pro">Edit profile</button>
</a>
</div>
<div class="pro_details edit_details">
<h2>Edit Details</h2>
<hr class="conf_hr">
<div class="profile_details">
<strong>
<p>Infinito ID</p>
</strong>
<p><?php
echo $infid;
?></p>
</div>
<div class="profile_details">
<strong>
<p>Email</p>
</strong>
<p><?php
$sql="SELECT * FROM `infinito2021php` where `InfId`='$infid'";
$result=mysqli_query($conn,$sql);
if ($result) {
$row=mysqli_fetch_assoc($result);
echo $row['Email'];
}
?></p>
</div>
<div class="profile_details">
<strong>
<p>College ID/ Roll No.</p>
</strong>
<p><?php
$sql="SELECT * FROM `infinito2021php` where `InfId`='$infid'";
$result=mysqli_query($conn,$sql);
if ($result) {
$row=mysqli_fetch_assoc($result);
echo $row['ID'];
}
?></p>
</div>
<div class="profile_details">
<strong>
<p>Gender</p>
</strong>
<p><?php
$sql="SELECT * FROM `infinito2021php` where `InfId`='$infid'";
$result=mysqli_query($conn,$sql);
if ($result) {
$row=mysqli_fetch_assoc($result);
echo $row['Gender'];
}
?></p>
</div>
<form method="post" action=<?php echo $_SERVER['REQUEST_URI'];?>>
<?php
$sql="SELECT * FROM `infinito2021php` where `InfId`='$infid'";
$result=mysqli_query($conn,$sql);
if ($result) {
$row=mysqli_fetch_assoc($result);
echo '
<div class="profile_details">
<p><label for="inputPassword3" class="col-form-label">Name</label></p>
<div class="edit_fill">
<input class="edit-fill-form" type="text" class="form-control" id="inputPassword3" name="name" value="'.$row['Name'].'" required>
</div>
</div>
<div class="profile_details">
<p><label for="inputPassword3" class="col-form-label">College Name (FULL)</label></p>
<div class="edit_fill">
<input class="edit-fill-form" type="text" class="form-control" id="inputPassword3" name="clg" value="'.$row['College'].'" required>
</div>
</div>
<div class="profile_details">
<p><label for="phone" class=" col-form-label">Phone Number</label></p>
<div class="edit_fill">
<input class="edit-fill-form" type="text" class="form-control" id="inputPassword3" name="phno" value="'.$row['Phone Number'].'" required>
</div>
</div>
<div style="margin-top:2px;">
<input type="checkbox" name="changePass" id="changePass" onclick="displayPass()" value="changePass">
<label for="changePass">Change Password</label><br>
</div>
<div id="change_password"></div>
<div class="profile_details">
<div>
<button type="button" class="btn btn-primary" name="update" onclick="checkPass()" id="updateProfile" >Update</button>
</div>
</div>';
}
?>
</form>
</div>
</div>
<?php
require('./templates/footer.php');
?>
<script>
function displayPass(){
var display = "";
if(document.getElementById("changePass").checked == true){
display = '<div class="profile_details"><p><label for="newPass" class="col-form-label">Password</label></p><div class="edit_fill"><input class="edit-fill-form" type="password" class="form-control" id="newPass" name="password" value="" required></div></div>';
display += '<div class="profile_details"><p><label for="ConfNewPass" class="col-form-label">Confirm Password</label></p><div class="edit_fill"><input class="edit-fill-form" type="password" class="form-control" id="confNewPass" name="confPassword" value="" required><div id="passError"></div>';
display += '<div style="margin-top:5px;"><input type="checkbox" name="showPass" id="showPass" onclick="showPassword()" style="margin-right:2px;"><label for="showPass">Show Password</label><br> </div></div></div>';
}
document.getElementById("change_password").innerHTML = display;
}
function checkPass(){
if(document.getElementById("changePass").checked == true){
if(document.getElementById("newPass").value == document.getElementById("confNewPass").value){
var updateProfile = document.getElementById("updateProfile");
updateProfile.setAttribute('type', 'submit');
}
else{
document.getElementById("confNewPass").style.color = "red";
document.getElementById("passError").innerHTML = '<p style="color:red;">Passwords do not match.<p>';
}
}
else{
var updateProfile = document.getElementById("updateProfile");
updateProfile.setAttribute('type', 'submit');
}
}
function showPassword(){
if(document.getElementById("showPass").checked == true){
document.getElementById("newPass").setAttribute('type','text');
document.getElementById("confNewPass").setAttribute('type','text');
console.log("checked");
}
else{
document.getElementById("newPass").setAttribute('type','password');
document.getElementById("confNewPass").setAttribute('type','password');
}
}
</script>
</body>
</html>