forked from Puja0708/Online-Examination-Software
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditprofile.php
More file actions
170 lines (142 loc) · 6.82 KB
/
editprofile.php
File metadata and controls
170 lines (142 loc) · 6.82 KB
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
/*
****************************************************
*** Online Examination System ***
*** Title: Edit Profile ***
****************************************************
*/
/* Procedure
*********************************************
* ----------- *
* PHP Section *
* ----------- *
Step 1: Perform Session Validation.
Step 2: Event to Process...
Case 1 : Logout - perform session cleanup.
Case 2 : Dashboard - redirect to Dashboard.
Case 3 : Edit - Update the Information.
* ------------ *
* HTML Section *
* ------------ *
Step 3: Display the HTML Components for...
Case 1: Default Mode - Displays the saved information.
*********************************************
*/
error_reporting(0);
session_start();
include_once 'oesdb.php';
/************************** Step 1 *************************/
if(!isset($_SESSION['stdname'])) {
$_GLOBALS['message']="Session Timeout.Click here to <a href=\"index.php\">Re-LogIn</a>";
}
else if(isset($_REQUEST['logout']))
{
/************************** Step 2 - Case 1 *************************/
//Log out and redirect login page
unset($_SESSION['stdname']);
header('Location: index.php');
}
else if(isset($_REQUEST['dashboard'])){
/************************** Step 2 - Case 2 *************************/
//redirect to dashboard
header('Location: stdwelcome.php');
}else if(isset($_REQUEST['savem']))
{
/************************** Step 2 - Case 3 *************************/
//updating the modified values
if(empty($_REQUEST['cname'])||empty ($_REQUEST['password'])||empty ($_REQUEST['email']))
{
$_GLOBALS['message']="Some of the required Fields are Empty.Therefore Nothing is Updated";
}
else
{
$query="update student set stdname='".htmlspecialchars($_REQUEST['cname'],ENT_QUOTES)."', stdpassword=ENCODE('".htmlspecialchars($_REQUEST['password'],ENT_QUOTES)."','oespass'),emailid='".htmlspecialchars($_REQUEST['email'],ENT_QUOTES)."',contactno='".htmlspecialchars($_REQUEST['contactno'],ENT_QUOTES)."',address='".htmlspecialchars($_REQUEST['address'],ENT_QUOTES)."',city='".htmlspecialchars($_REQUEST['city'],ENT_QUOTES)."',pincode='".htmlspecialchars($_REQUEST['pin'],ENT_QUOTES)."' where stdid='".$_REQUEST['student']."';";
if(!@executeQuery($query))
$_GLOBALS['message']=mysql_error();
else
$_GLOBALS['message']="Your Profile is Successfully Updated.";
}
closedb();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>OES-Edit Profile</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="oes.css"/>
<script type="text/javascript" src="validate.js" ></script>
</head>
<body >
<?php
if($_GLOBALS['message']) {
echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
}
?>
<div id="container">
<div class="header"><h3 class="headtext"> Online Examination System </h3><h4 style="color:#ffffff;text-align:center;margin:0 0 5px 5px;">
</div>
<form id="editprofile" action="editprofile.php" method="post">
<div class="menubar">
<ul id="menu">
<?php if(isset($_SESSION['stdname'])) {
// Navigations
?>
<li><input type="submit" value="LogOut" name="logout" class="subbtn" title="Log Out"/></li>
<li><input type="submit" value="DashBoard" name="dashboard" class="subbtn" title="Dash Board"/></li>
<li><input type="submit" value="Save" name="savem" class="subbtn" onclick="validateform('editprofile')" title="Save the changes"/></li>
</ul>
</div>
<div class="page">
<?php
/************************** Step 3 - Case 1 *************************/
// Default Mode - Displays the saved information.
$result=executeQuery("select stdid,stdname,DECODE(stdpassword,'oespass') as stdpass ,emailid,contactno,address,city,pincode from student where stdname='".$_SESSION['stdname']."';");
if(mysql_num_rows($result)==0) {
header('Location: stdwelcome.php');
}
else if($r=mysql_fetch_array($result))
{
//editing components
?>
<table cellpadding="20" cellspacing="20" style="text-align:left;margin-left:15em" >
<tr>
<td>User Name</td>
<td><input type="text" name="cname" value="<?php echo htmlspecialchars_decode($r['stdname'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" value="<?php echo htmlspecialchars_decode($r['stdpass'],ENT_QUOTES); ?>" size="16" onkeyup="isalphanum(this)" /></td>
</tr>
<tr>
<td>E-mail ID</td>
<td><input type="text" name="email" value="<?php echo htmlspecialchars_decode($r['emailid'],ENT_QUOTES); ?>" size="16" /></td>
</tr>
<tr>
<td>Contact No</td>
<td><input type="text" name="contactno" value="<?php echo htmlspecialchars_decode($r['contactno'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)"/></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="address" cols="20" rows="3"><?php echo htmlspecialchars_decode($r['address'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>City</td>
<td><input type="text" name="city" value="<?php echo htmlspecialchars_decode($r['city'],ENT_QUOTES); ?>" size="16" onkeyup="isalpha(this)"/></td>
</tr>
<tr>
<td>PIN Code</td>
<td><input type="hidden" name="student" value="<?php echo $r['stdid']; ?>"/><input type="text" name="pin" value="<?php echo htmlspecialchars_decode($r['pincode'],ENT_QUOTES); ?>" size="16" onkeyup="isnum(this)" /></td>
</tr>
</table>
<?php
closedb();
}
}
?>
</div>
</form>
</div>
</body>
</html>