forked from ictslgti/sis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoticeAddResult.php
More file actions
255 lines (180 loc) · 7.25 KB
/
Copy pathNoticeAddResult.php
File metadata and controls
255 lines (180 loc) · 7.25 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
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
<!-- bLOCK#1 start don't change the order-->
<?php
$title =" Department Deatils| SLGTI";
include_once("config.php");
include_once("head.php");
include_once("menu.php");
?>
<!-- end don't change the order-->
<!-- bLOCK#2 start your code here & u can change -->
<br>
<hr>
<div class="alert bg-dark text-white text-center" role="alert"><h1>SriLanka German Training Institute<br>Notice Add Result.</h1>
</div>
<br>
<hr>
<br>
<?PHP
$department_id=$course_id=$module_id=$academic_year=$tid=null;
if(isset($_GET['edit']))
{
$id = $_GET['edit'];
$sql = "SELECT * FROM `notice_result` WHERE `result_id` = $id";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result)==1)
{
$row = mysqli_fetch_assoc($result);
$result_id = $row['result_id'];
$department_id = $row['department_id'];
$course_id = $row['course_id'];
$module_id = $row['module_id'];
$academic_year= $row['academic_year'];
$upload= $row['upload'];
}
}
// Add coding
?>
<!-- Add timetable design -->
<form method="POST" action="" enctype="multipart/form-data">
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label"><h5> Department</h5></label>
<div class="col-sm-10">
<select id="inputState" class="form-control<?php if(isset($_POST['Add']) && empty($_POST['department_id']))
{echo ' is-invalid';}if(isset($_POST['Add']) && !empty($_POST['department_id'])){echo ' is-valid';} ?>" id="department_id" name="department_id">
<option selected disabled>Department</option>
<?php
$sql="SELECT * from department";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0)
while($row = mysqli_fetch_assoc($result))
{
echo '<option value="'.$row['department_id'].'"';
if ($row["department_id"]==$department_id )
{
echo 'selected';
}
echo '>'.$row['department_name'].'</option>';
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 col-form-label"><h5> Course</h5></label>
<div class="col-sm-10">
<select id="inputState" class="form-control <?php if(isset($_POST['Add']) && empty($_POST['course_id']))
{echo ' is-invalid';}if(isset($_POST['Add']) && !empty($_POST['course_id'])){echo ' is-valid';} ?>" id="course_id" name="course_id">
<option selected disabled required>Course</option>
<?php
$sql = "SELECT * FROM `course`";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo '<option value="'.$row["course_id"].'" required';
if($row["course_id"]==$course_id) echo ' selected';
echo '>'.$row["course_name"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label"><h5> Module</h5></label>
<div class="col-sm-10">
<select id="inputState" class="form-control<?php if(isset($_POST['Add']) && empty($_POST['module_id']))
{echo ' is-invalid';}if(isset($_POST['Add']) && !empty($_POST['module_id'])){echo ' is-valid';} ?>" id="module_id" name="module_id">
<option selected disabled required >Module</option>
<?php
$sql = "SELECT * FROM `module`";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo '<option value="'.$row["module_id"].'" required';
if($row["module_id"]==$module_id) echo ' selected';
echo '>'.$row["module_name"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label"><h5> AcademicYear</h5></label>
<div class="col-sm-10">
<select id="inputState" class="form-control<?php if(isset($_POST['Add']) && empty($_POST['academic_year']))
{echo ' is-invalid';}if(isset($_POST['Add']) && !empty($_POST['academic_year'])){echo ' is-valid';} ?>" id="academic_year" name="academic_year">
<option selected disabled required >AcademicYear</option>
<?php
$sql = "SELECT * FROM `academic`";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo '<option value="'.$row["academic_year"].'" required';
if($row["academic_year"]==$academic_year) echo ' selected';
echo '>'.$row["academic_year"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="input-group mb-3">
<label for="inputEmail3" class="col-sm-2 col-form-label"><h5>Upload Your File</h5></label>
<input class="form-control" type="file" name='pdf' value="<?php if(isset($_POST['Add']) && empty($_POST['upload']))
{echo ' is-invalid';}if(isset($_POST['Add']) && !empty($_POST['upload'])){echo ' is-valid';} ?>" id="upload" name="upload"></td>
</div>
<div class="col-12">
<h1 class="text-right">
<?PHP
echo '<div class="btn-group-horizontal">';
if(isset($_GET['edit']))
{
echo '<button type="submit" class="btn btn-primary mr-2"><i class="fas fa-user-edit"></i>UPDATE</button>';
echo'<button type="reset" value="Reset" class="btn btn-primary mr-2"><i class="fas fa-redo"></i>REFRESH</button>';
}
if(isset($_GET['delete']))
{
echo '<button type="submit" class="btn btn-danger mr-2"><i class="fas fa-user-slash"></i>DELETE</button>';
}
if(!isset($_GET['delete']) && !isset($_GET['edit'])){
echo '<button type="submit" value="Add" name="Add" class="btn btn-primary mr-2"><i class="fas fa-user-plus"></i> ADD</button>';
}
echo '</div>';
?>
<a href="NoticeResultTable.php" class="btn btn-sm btn-warning"><i class="far fa-edit"></i> View</a></button>
</div>
</div>
</form>
<?php
if(isset($_POST['Add'])){
if(!empty($_POST['department_id'])
&&!empty($_POST['course_id'])
&&!empty($_POST['module_id'])
&&!empty($_POST['academic_year']))
{
$department_id = $_POST['department_id'];
$course_id = $_POST['course_id'];
$module_id = $_POST['module_id'];
$academic_year = $_POST['academic_year'];
$t_name = $_FILES["pdf"]["tmp_name"];
$name = basename($_FILES["pdf"]["name"]);
$test_dir = './docs/result';
move_uploaded_file($t_name, $test_dir.'/'.$name);
if ($name){
echo "Successfully uploaded";
}else{
echo "Not uploaded because of error #".$_FILES["ima"]["error"];
}
$sql = "INSERT INTO `notice_result` (`department_id`, `academic_year`,`course_id`, `module_id` ,`upload`)
VALUES ('$department_id','$academic_year','$course_id','$module_id','$name')";
if (mysqli_query($con, $sql)) {
echo "record add";
} else {
echo "Error: " . $sql .
"<br>" . mysqli_error($con);
}
}
}
?>
<?php include_once("footer.php"); ?>