-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusersprofile.php
187 lines (176 loc) · 4.52 KB
/
usersprofile.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
<?php
include("header.php");
if($_POST[setid] == $_SESSION[setid])
{
if(isset($_POST[submit]))
{
$sql="UPDATE users SET courseid=$_POST[course], name=$_POST[name], designation=$_POST[designation],username=$_POST[username],password=$_POST[password] WHERE userid=$_SESSION[examinerid]";
if (!mysqli_query($con,$sql))
{
die(Error: . mysqli_error($con));
}
else
{
$res = "<font color=green>Record updated successfully...</font>";
$resi=1;
}
}
}
$_SESSION[setid]=rand();
$sql="SELECT * FROM users where userid=$_SESSION[examinerid]";
$qres= mysqli_query($con,$sql);
$rs = mysqli_fetch_array($qres);
?>
<div class="slider_top2">
<h2>User Profile</h2>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div class="left">
<p>
<form name="formname" method=post action="" onsubmit="return validation()">
<input type="hidden" name="setid" value="<?php echo $_SESSION[setid]; ?>" />
<table class="tftable" border="1" style="width: 100%;">
<?php
if($resi==1)
{
echo "<tr> <th colspan=2> $res</th> </tr>";
}
?>
<tr>
<th width="169" scope="col">Name</th>
<td width="415" scope="col">
<input type="text" name="name" id="name" value="<?php echo $rs[name]; ?>" placeholder="Enter Name" /></td>
</tr>
<tr>
<th scope="row">Course</th>
<td><label for="course"></label>
<?php
$result = mysqli_query($con,"Select * from course where status=Enabled");
?>
<select name="course" id="course">
<?php
while($rs1 = mysqli_fetch_array($result))
{
if($rs[courseid] == $rs1[courseid])
{
echo "<option value=$rs1[courseid] selected>$rs1[coursename]</option>";
}
}
?>
</select></td>
</tr>
<tr>
<th scope="row">Designation</th>
<td><label for="designation"></label>
<input type="text" name="designation" id="designation" value="<?php echo $rs[designation]; ?>" placeholder="Enter Designation"/></td>
</tr>
<tr>
<th scope="row">User Type</th>
<td><select name="usertype">
<?php
$arr = array("Examiner","Administrator");
foreach($arr as $val)
{
if($val == $rs[usertype])
{
echo "<option value=$val selected >$val</option>";
}
}
?>
</select></td>
</tr>
<tr>
<th scope="row">User Name</th>
<td><label for="username"></label>
<input type="text" name="username" id="username" value="<?php echo $rs[username]; ?>" placeholder="Enter User Name" /></td>
</tr>
<tr>
<th scope="row">Password</th>
<td><label for="password"></label>
<input type="password" name="password" id="password" value="<?php echo $rs[password]; ?>" placeholder="Enter Password"/></td>
</tr>
<tr>
<th scope="row">Confirm Password</th>
<td><input type="password" name="confirmpassword" id="confirmpassword" value="<?php echo $rs[password]; ?>" placeholder="Enter Password"/></td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="submit" id="submit" value="Update Profile" /></th>
</tr>
</table>
</form>
</p>
<p> </p>
<p> </p>
</div>
<div class="right">
<?php
include("usersidebar.php");
?>
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>
<script type="application/javascript">
function validation()
{
if(formname.name.value=="")
{
alert("Please Enter Name...");
formname.name.focus();
return false;
}
else if(formname.course.value=="Select")
{
alert("Please Select Course...");
formname.course.focus();
return false;
}
else if(formname.designation.value=="")
{
alert("Please Enter Designation...");
formname.designation.focus();
return false;
}
else if(formname.usertype.value=="")
{
alert("Please Enter Usertype...")
formname.usertype.focus();
return false;
}
else if(formname.username.value=="")
{
alert("Please Enter Username...")
formname.username.focus();
return false;
}
else if(formname.password.value=="")
{
alert("Please Enter Password...")
formname.password.focus();
return false;
}
else if(formname.password.value != formname.confirmpassword.value)
{
alert("Password and confirm password not matching..")
formname.password.value="";
formname.confirmpassword.value="";
formname.password.focus();
return false;
}
else if(formname.status.value=="")
{
alert("Please Enter Status...")
formname.status.focus();
return false;
}
else
{
return true;
}
}
</script>