-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateadmin.php
227 lines (216 loc) · 6.08 KB
/
updateadmin.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
session_start();
include("includes/header.php");
include("includes/conn.php");
if(isset($_POST[submit]))
{
mysqli_query($con,"UPDATE admin SET branch_id = $_POST[bname],admin_name = $_POST[aname],login_id = $_POST[loginid],email_id = $_POST[emailid] WHERE admin_id =$_SESSION[admin_id]");
if(mysqli_affected_rows($con) == 1)
{
$resvar = "<b><font color=#009900>Admin records updated successfully</font></b>";
}
else
{
$resvar= "<b><font color=#FF0000>Failed to update profile</font></b>";
}
}
if(isset($_GET[adminid]))
{
$resadminrec = mysqli_query($con,"Select * from admin where admin_id=$_GET[adminid]");
}
else
{
$resadminrec = mysqli_query($con,"Select * from admin where admin_id=$_SESSION[admin_id]");
}
$rowsadmin = mysqli_fetch_array($resadminrec);
$adminid = $rowsadmin[admin_id];
$brid = $rowsadmin[branch_id];
$adname = $rowsadmin[admin_name];
$loginid= $rowsadmin[login_id];
$password = $rowsadmin[password];
$email_id = $rowsadmin[email_id];
?>
<div id="templatemo_main">
<div id="sidebar" class="float_l">
<div class="sidebar_box"><span class="bottom"></span>
<?php
include("sidebar.php");
adminhome();
?>
</div>
</div>
<div id="content" class="float_r">
<h1>Update Admin Profile</h1>
<p><?php echo $resvar; ?></p>
<script type="application/javascript" >
function validation()
{
//Validation for Email ID
em = document.form1.emailid.value;
pos1 = em.indexOf("@")
pos = em.indexOf(" ")
pos2 = (pos1+1)
server = em.substring(pos2);
server_pos = server.lastIndexOf(".")
reqtype = server.substring(server_pos+1)
type_end = reqtype.substring(reqtype.length-1)
//Email ID
// return false
if(document.form1.aname.value == "")
{
alert("Enter Name");
document.form1.aname.focus();
return false;
}
if(document.form1.password.value == "")
{
alert("Enter Password");
document.form1.password.focus();
return false;
}
if(document.form1.cpassword.value == "")
{
alert("Confirm The Password");
document.form1.cpassword.focus();
return false;
}
if(document.form1.password.value != document.form1.cpassword.value)
{
alert("Password not Matching...");
return false;
}
else if(em == "")
{
document.form1.emailid.focus();
alert("Email cannot be blank");
return false;
}
else if(em.length<8)
{
document.form1.emailid.focus();
alert("Email length cannot be less than 8 characters");
return false;
}
else if(em.indexOf("@")==-1)
{
document.form1.emailid.focus();
alert("The Email Address must contain @ sign");
return false;
}
else if(pos1<1)
{
document.form1.emailid.focus();
alert("Email address cannot start with @ sign");
return false;
}
else if(em.indexOf(".")==-1)
{
document.form1.emailid.focus();
alert("The Email Address must contain . sign");
return false;
}
else if(pos!=-1)
{
document.form1.emailid.focus();
alert("The Email Address cannot contain spaces");
return false;
}
else if(server.indexOf("@")!=-1)
{
document.form1.emailid.focus();
alert("A valid Email must contain only one @ sign");
return false;
}
else if(server.indexOf(".")==0)
{
document.form1.emailid.focus();
alert("There should some text between @ and . sign");
return false;
}
else if(reqtype=="")
{
document.form1.emailid.focus();
alert("Email Id should end with character(like .com,.net,.org)");
return false;
}
else if(type_end.toUpperCase()<"A" || type_end.toUpperCase()>"Z")
{
document.form1.emailid.focus();
alert("Email Id should not end with number or symbol");
return false;
}
if(document.form1.bname.value=="")
{
alert("Select Branch Name");
return false;
}
}
</script>
<form name="form1" id="form1" method="post" action="" onsubmit="return validation()">
<table width="595" border="0">
<tr>
<td width="127" height="40"><label for="aname" class="left">Admin Name:</label></td>
<td width="458"><label for="aname" class="left"></label>
<input type="hidden" name="adminid" value="<?php echo $adminid;?>" />
<input class="right" name="aname" type="text" id="aname" size="50" value="<?php echo $adname ;?>"/></td>
</tr>
<tr>
<td height="35"><label class="left" for="loginid" >Login ID:</label></td>
<td><input class="right" name="loginid" type="text" id="loginid" size="50" readonly="readonly" value="<?php echo $loginid ;?>" /></td>
</tr>
<tr>
<td height="35">Email-ID</td>
<td><input name="emailid" type="text" id="emailid" size="50" value="<?php echo $email_id;?>" /></td>
</tr>
<tr>
<td height="45"><label for="contact" class="left">Branch Name:</label></td>
<td>
<?php
$resadminreca = mysqli_query($con,"Select * from branch");
?>
<select name="bname" id="bname">
<option value="">Select</option>
<?php
while($rowsa = mysqli_fetch_array($resadminreca))
{
if($brid == $rowsa["branch_id"])
{
echo "<option value=$rowsa[branch_id] selected=selected>$rowsa[branch_name]</option>";
}
else
{
echo "<option value=$rowsa[branch_id]>$rowsa[branch_name]</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td height="35" align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Update Admin" class="buttonabc"/></td>
</tr>
</table>
</form>
<div id="content_main"><p></p>
<p><br />
</p>
<p><br />
<br />
<br />
<br />
</p>
<p><br />
<br />
</p>
<p>
<center>
</center>
</p>
<p> </p>
</div>
<div class="cleaner"></div>
</div>
<div class="cleaner"></div>
</div>
<?php
include("includes/footer.php");
?>