-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_thoe_course.php
341 lines (319 loc) · 9.36 KB
/
add_thoe_course.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<?php
session_start();
//checking user is logged in or not
if(!isset($_SESSION['user_id'])){
echo '<script language="javascript">';
echo 'alert("Please LogIn First")';
echo '</script>';
header('Location: admin.php');
exit();
}
require 'Classes/PHPExcel/IOFactory.php';
include('includes/db.php');
// Mysql database
//$servername = "localhost";
//$username = "root";
//$password = "root";
//$dbname = "test";
if(isset($_POST["delete"]))
{
$sql = "TRUNCATE TABLE `theory_course`";
if (mysqli_query($db, $sql)) {
echo '<script language="javascript">';
echo 'alert("Data deleted..!")';
echo '</script>';
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($db);
}
}
if(isset($_POST["import"]))
{
$extension = end(explode(".", $_FILES["excel"]["name"])); // For getting Extension of selected file
//$ext = GetImageExtension($exl_type);
$allowed_extension = array("xls", "xlsx", "csv"); //allowed extension
if(in_array($extension, $allowed_extension)) //check selected file extension is present in allowed extension array
{
$inputfilename = $_FILES["excel"]["tmp_name"]; // getting temporary source of excel file
$exceldata = array();
// Create connection
//$conn = mysqli_connect($servername, $username, $password, $dbname);
/*/ Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
*/
// Read your Excel workbook
try
{
$inputfiletype = PHPExcel_IOFactory::identify($inputfilename);
$objReader = PHPExcel_IOFactory::createReader($inputfiletype);
$objPHPExcel = $objReader->load($inputfilename);
}
catch(Exception $e)
{
/*die('Error loading file "'.pathinfo($inputfilename,PATHINFO_BASENAME).'": '.$e->getMessage());*/
}
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// Loop through each row of the worksheet in turn
for ($row = 2; $row <= $highestRow; $row++)
{
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
// Insert row data array into your database of choice here
$sql = "INSERT INTO theory_course (T_Course_Code, T_Course_Name, Year, Semester)
VALUES ('".$rowData[0][0]."', '".$rowData[0][1]."', '".$rowData[0][2]."', '".$rowData[0][3]."')";
if (mysqli_query($db, $sql)) {
$exceldata[] = $rowData[0];
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($db);
}
}
/*/ Print excel data
echo "<table>";
foreach ($exceldata as $index => $excelraw)
{
echo "<tr>";
foreach ($excelraw as $excelcolumn)
{
echo "<td>".$excelcolumn."</td>";
}
echo "</tr>";
}
echo "</table>";
*/
mysqli_close($db);
header('Location: add_prac_course.php');
exit();
}
else
{
echo '<label class="text-danger">Invalid File</label>'; //if non excel file then
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">
<title>SKN Feedback</title>
<!-- Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/navbar-top-fixed.css" rel="stylesheet">
<style type="text/css">
.bg-dark {
background-color: #5213b3!important;
}
body{
background:#616161;
}
.jumbotron {
padding: 4rem 2rem;
margin-bottom: 2rem;
background-color: #cecece;
border-radius: .3rem;
}
.btn-lg {
border-radius: 4rem;
}
.form-style-10{
max-width:750px;
padding:30px;
margin:60px auto;
background: #cecece;
border-radius: 10px;
-webkit-border-radius:10px;
-moz-border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
}
.form-style-10 .inner-wrap{
padding: 30px;
background: #F8F8F8;
border-radius: 6px;
margin-bottom: 15px;
}
.form-style-10 h1{
background: #3d0c88;
padding: 20px 30px 15px 30px;
margin: -30px -30px 30px -30px;
border-radius: 10px 10px 0 0;
-webkit-border-radius: 10px 10px 0 0;
-moz-border-radius: 10px 10px 0 0;
color: #fff;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12);
font: normal 30px 'Bitter', serif;
-moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
-webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
border: 1px solid #257C9E;
}
.form-style-10 h1 > span{
display: block;
margin-top: 2px;
font: 13px Arial, Helvetica, sans-serif;
}
.form-style-10 label{
display: block;
font: 13px Arial, Helvetica, sans-serif;
color: #888;
margin-bottom: 15px;
}
.form-style-10 input[type="text"],
.form-style-10 input[type="date"],
.form-style-10 input[type="datetime"],
.form-style-10 input[type="email"],
.form-style-10 input[type="number"],
.form-style-10 input[type="search"],
.form-style-10 input[type="time"],
.form-style-10 input[type="url"],
.form-style-10 input[type="password"],
.form-style-10 textarea,
.form-style-10 select {
display: block;
font-family: Georgia, "Times New Roman", Times, serif;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
padding: 8px;
border-radius: 6px;
-webkit-border-radius:6px;
-moz-border-radius:6px;
border: 2px solid #fff;
color:#607D8B;
box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
-moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
-webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
}
.form-style-10 .section{
font: normal 20px 'Bitter', serif;
color: #3d0c88;
margin-bottom: 5px;
}
.form-style-10 .subject{
font: normal 15px 'Bitter', serif;
color: #000000;
margin-bottom: 5px;
}
.form-style-10 .section span {
background: #5213b3;
padding: 5px 10px 5px 10px;
position: absolute;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border: 4px solid #fff;
font-size: 14px;
margin-left: -45px;
color: #fff;
margin-top: -3px;
}
.btn-primary {
color: #fff;
background-color: #5213b3;
border-color: #5213b3;
}
.form-style-10 input[type="button"],
.form-style-10 input[type="submit"]{
background: #5213b3;
padding: 8px 20px 8px 20px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
color: white;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12);
font: normal 30px 'Bitter', serif;
-moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
-webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
border: 1px solid #257C9E;
font-size: 15px;
}
.form-style-10 input[type="button"]:hover,
.form-style-10 input[type="submit"]:hover{
background: #5213b3;
-moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
-webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
}
.form-style-10 .privacy-policy{
float: right;
width: 250px;
font: 12px Arial, Helvetica, sans-serif;
color: #4D4D4D;
margin-top: 10px;
text-align: right;
}
a {
color: #f8f9fa;
text-decoration:none;
background-color: transparent; // Remove the gray background on active links in IE 10.
-webkit-text-decoration-skip: objects; // Remove gaps in links underline in iOS 8+ and Safari 8+.
@include hover {
color: $e9ecef;
text-decoration: none;
}
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
</ul>
<a class="nav-item nav-link active" href="ad_home.php">Home <span class="sr-only">(current)</span></a>
<a class="nav-link" href="login.php">Student Login</a>
</div>
</nav>
<div class="form-style-10">
<h1>Add Details for feedback</h1>
<main role="main" class="container">
<center><div class="jumbotron col-sm-10">
<h2>Add theory Courses</h2>
<br>
<table>
<tr>
<th>
<form action="#" method="post" enctype="multipart/form-data">
<div class="form-group">
<input type="file" class="form-control" id="excel" name="excel" required>
</div>
</th>
<td>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-18">
<button type="submit" name="import" class="btn btn-lg btn-primary btn-block">Submit</button>
</div>
</div>
</form>
</td>
</tr><tr><td></td></tr><tr></tr>
<tr>
<th>
<div class="col-sm-18">
<button type="submit" class="btn btn-lg btn-success btn-block">View Previous File</button>
</div>
</th>
<td>
<form action="#" method="post">
<div class="col-sm-offset-2 col-sm-18">
<button type="submit" name="delete" class="btn btn-lg btn-danger btn-block">Delete</button>
</form>
</div>
</td>
</tr>
</table>
</div> </center>
</main>
</div>
</body>
</html>