-
Notifications
You must be signed in to change notification settings - Fork 0
/
chooseuser (2).php
318 lines (307 loc) · 9.04 KB
/
chooseuser (2).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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<?php
session_start();
include("includes/connect.php");
if (!$_SESSION['deanp']) {
header("location:index.php");
}
$tid=$_SESSION['deanp'];
$sqli=mysql_query("SELECT *FROM dean WHERE id='$tid'") or die(mysql_error());
$rowtitle=mysql_fetch_array($sqli);
//echo "<script>alert('$tid')</script>";
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $rowtitle['firstname']." ".$rowtitle['lastname'];?></title>
<?php
include("includes/banner.php");
include("includes/header.php");
?>
<link rel="stylesheet" type="text/css" href="css/chooseuser.css">
<style type="text/css">
#fter{background-color: #5da1a7;height:60px;margin-top: 400px;font-family:corbel;text-align: center;
padding-top: 3px;position: fixed;z-index: 1px;width: 1200px;
}
</style>
</head>
<body>
<div id="indcontent">
<div class="action"><!--this is the division of student links-->
<div id="fter">
<h3>Allright reserved © Mucyo Rene</h3>
</div>
<div id="blankspace">
<!--======================================this is the page where admin will choose use to be added
===========================================================-->
<div>
<div id="open"style="display:inline-block;font-size:150%;margin-left:10%;color:none;">
<label>Add student</label>
</div>
<div id="openx"style="display:inline-block;font-size:150%;margin-left:10%;color: none;">
<label>Add Teachers</label>
</div>
<div id="listt" style="display:none;">
<!--teacher contents-->
<table border="0" style="margin-left:20%;">
<form method="POST">
<tr>
<td id="tds">Firstname</td><td><input type="text" pattern="[A-Za-z']{2,30}" required name="fname1" placeholder="Teacher's firstname"size="20" class="inp" title="Enter the teacher's firstname"></td>
</tr>
<tr>
<td id="tds">Lastname</td><td><input type="text" pattern="[A-Za-z']{2,30}" required name="lname" placeholder="Teacher's lastname" size="20" class="inp" title="Enter the teacher's lastname"></td>
</tr>
<tr>
<td id="tds">Sex</td><td width="40"><center>
<select name="gender" required title="Select gender">
<option value="">--Select--</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</center>
</td>
</tr>
<tr>
<td id="tds">id numbers</td><td><input type="text" pattern="119[0-9]{13}" required name="idcard" placeholder="Teacher identity card number"size="20" title="enter the teacher's id" class="inp"></td>
</tr>
<tr>
<td id="tds">Address</td><td>
<select name="location">
<option>--Select--</option>
<?php
$dis=mysql_query("SELECT * FROM district");
while ($loa=mysql_fetch_array($dis)) {
?>
<option value="<?= $loa['district_id'];?>"><?= $loa['district_name'];?></option>
<?php
}
?>
</select>
</tr>
<tr>
<td id="tds">Phones</td><td>
<input type="text" required name="phone1" placeholder="Teacher's phone" size="20" class="inp"
pattern="07[2,3,8]{1}[0-9]{7}" title="Provide the Rwandan valid phone number"></td>
</tr>
<tr>
<td id="tds">Qualification</td><td>
<select name='qualify' required style="padding-right:30%;">
<option>A2</option>
<option>A1</option>
<option>A0</option>
<option>Postgraduate</option>
</select>
</td>
</tr>
</tr>
<tr>
<td id="tds">Email</td><td><input required type="email" name="mail"
placeholder="Teacher's email" size="20" class="inp" title="Enter the teacher's email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]{6,5}+\.[a-z]{2,3}$"></td>
</tr>
</tr>
<tr>
<td colspan="3" align="right" height="25" width="60">
<input type="submit" name="save" value="Sign up" class="sub"></td>
</tr>
</form>
</table>
</div>
<script src="java/jquery.js"></script>
<script src="java/jquery-ui.js"></script>
<link rel="stylesheet"href="java/jquery-ui.css">
<script>
$(document).ready(function(){
$("#listt").hide(500);
$("#openx").click(function(){
$("#lists").hide(200);
$("#listt").slideToggle();
});
});
</script>
<?php
if (isset($_POST['save'])) {
$a=mysql_real_escape_string($_POST['fname1']);
$b=mysql_real_escape_string($_POST['lname']);
$c=mysql_real_escape_string($_POST['gender']);
$d=mysql_real_escape_string($_POST['idcard']);
$e=mysql_real_escape_string($_POST['location']);
$f=mysql_real_escape_string($_POST['phone1']);
$g=mysql_real_escape_string($_POST['qualify']);
$h=mysql_real_escape_string($_POST['mail']);
$i=$b;
$j=$a.date("y");
$checi=mysql_query("SELECT * FROM teachers WHERE firstname='$a' AND lastname='$b' AND idnumber='$d'") or die(mysql_error());
if (mysql_num_rows($checi)>0) {
echo "<script>alert(' $a $b already registered')</script>";
}else{
$e="INSERT INTO teachers VALUES(' ','$a','$b','$c','$d','$e','$f','$g','$h','$i','$j')";
$sql=mysql_query($e);
if ($sql) {
?>
<script>
alert("Teacher inserted");
</script>
<?php
}else{
?>
<script>
alert("can't insert plz");
</script>
<?php
echo "can't inserted";
}
}
}
?>
<div id="lists" style="display:none;">
<table border="0">
<form method="POST" enctype="multipart/form-data"action=''>
<tr>
<td id="tds">Firstname</td><td><input type="text" pattern="[A-Za-z']{2,30}" name="fname1" required title="provide student firstname" placeholder="Student's firstname"size="20" class="inp"></td>
</tr>
<tr>
<td id="tds">Lastname</td><td><input type="text" pattern="[A-Za-z']{2,30}" name="lname" required placeholder="Student's lastname" size="20" class="inp"></td>
</tr>
<tr>
<td id="tds">Gender</td><td width="40"><center><select name="gender" class="sex" colspan="3">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</center>
</td>
</tr>
<tr>
<td id="tds">Birth</td><td>
<?php
echo "<select name='sel' title='Enter valid year' required>";
echo "<option value=''>Y</option>";
$i=2016;
for ($i=2016; $i >=1800 ; $i--) {
echo "<option>".$i."</option>";
}//ending for loop
echo "</select>";
?>
<?php
echo "<select name='sele' required title='Enter valid month'>";
echo "<option value=''>"."M"."</option>";
$i=1;
for ($i=1; $i <=12 ; $i++) {
echo "<option>".$i."</option>";
}
echo "</select>";
?>
<?php
echo "<select name='select' required title='Enter valid day'>";
echo "<option value=''>"."D"."</option>";
$i=1;
for ($i=1; $i<=30 ; $i++) {
echo "<option>".$i."</option>";
}
echo "</select>";
?> </td>
</tr>
<tr>
<td id="tds">Address</td><td>
<select name="location" required>
<option value="">--Select--</option>
<?php
$dis=mysql_query("SELECT * FROM district");
while ($loa=mysql_fetch_array($dis)) {
?>
<option value="<?= $loa['district_id'];?>"><?= $loa['district_name'];?></option>
<?php
}
?>
</select>
</tr>
<tr>
<td id="tds">Phone</td><td><input type="text" required name="phone" placeholder="Student's phone" size="20" class="inp"
pattern="07[2,3,8]{1}[0-9]{7}" title="Provide the Rwandan valid phone number"></td>
</tr>
<tr>
<td id="tds">Fathername</td><td><input type="text" required name="fname" placeholder="Student's fathername" size="20" class="inp"></td>
</tr>
<tr>
<td id="tds">Mathername</td><td><input type="text" required name="mname" placeholder="Student's mathername" size="20" class="inp"></td>
</tr>
</tr>
<tr>
<td id="tds">Email</td><td><input type="email" required name="emails" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
placeholder="Student's email" size="20" class="inp"></td>
</tr>
<tr>
<td id="tds">class</td><td>
<select name="classe" required>
<option valu="">--Select--</option>
<?php
$sql=mysql_query("SELECT *FROM classes");
if ($sql) {
$i=1;
while ($d=mysql_fetch_array($sql)) {
echo "<option>".$d['classname']."</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Profile</td><td><input type="file" name="pic"/></td>
</tr>
<tr>
<td colspan="3" align="right" height="25" width="60"><input type="submit" name="saves" value="Sign up" class="sub"></td>
</tr>
</form>
</table>
<script>
$(document).ready(function(){
$("#lists").hide(500);
$("#open").click(function(){
$("#listt").hide(100);
$("#lists").slideToggle();
});
});
</script>
</div>
</div>
<?php
if (isset($_POST['saves'])) {
$a=mysql_real_escape_string($_POST['fname1']);
$b=mysql_real_escape_string($_POST['lname']);
$c=mysql_real_escape_string($_POST['gender']);
$d=mysql_real_escape_string($_POST['sel']."-".$_POST['sele']."-".$_POST['select']);
$e=mysql_real_escape_string($_POST['location']);
$f=mysql_real_escape_string($_POST['phone']);
$g=mysql_real_escape_string($_POST['fname']);
$h=mysql_real_escape_string($_POST['mname']);
$i=mysql_real_escape_string($_POST['emails']);
$l=mysql_real_escape_string($_FILES['pic']['name']);
$j=$b;
$k=$a.date("Y");
$cv=mysql_real_escape_string($_POST['classe']);
$checkid=mysql_query("SELECT * FROM students WHERE firstname='$a' AND lastname='$b' AND phones='$f'") or die(mysql_error());
if (mysql_num_rows($checkid)>0) {
echo "<script>alert('$a $b already registered')</script>";
}else{
$sq=mysql_query("SELECT *FROM classes WHERE classname='$cv'");
if ($sq) {
$row=mysql_fetch_array($sq);
$cl_id=$row['cl_id'];
}
$sql=mysql_query("INSERT INTO students VALUES
(' ','$a','$b','$c','$d','$e','$f','$g','$h','$i','$j','$k','$cl_id','$l','check')") or die(mysql_error());
move_uploaded_file($_FILES['pic']['tmp_name'], 'photos/'.$l);
if ($sql) {
echo "this is inserted";
}
else{
?>
<script>
alert("can't insert the people");
</script>
<?php
}
}
}
?>
</body>
</html>