-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotesuploadcode.php
More file actions
36 lines (32 loc) · 1.41 KB
/
notesuploadcode.php
File metadata and controls
36 lines (32 loc) · 1.41 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
<?php
include 'dbconfig.php';
session_start();
$teacher_id = $_SESSION['teacher_id'];
if (isset($_POST['Save_notes'])) {
$select = mysqli_query($conn, "SELECT * FROM `teacher` WHERE id = '$teacher_id'") or die('query failed');
if (mysqli_num_rows($select) > 0) {
$fetch = mysqli_fetch_assoc($select);
}
$title = mysqli_real_escape_string($conn, $_POST['title']);
$description = mysqli_real_escape_string($conn, $_POST['desc']);
$semester = mysqli_real_escape_string($conn, $_POST['semester']);
$tname = $fetch['name'];
$notes = $_FILES['notes']['name'];
$notes_size = $_FILES['notes']['size'];
$notes_tmp_name = $_FILES['notes']['tmp_name'];
$notes_folder = 'Teachernotes/'.$notes;
$query = mysqli_query($conn, "INSERT INTO `notesupload`(`notes_title`, `notes_desc`, `teacher_name`, `notesname`, `semester`,`teacher_id`)
VALUES ('$title','$description',' $tname','$notes',' $semester','$teacher_id')") or die ("Query failed");
if ($query) {
move_uploaded_file($notes_tmp_name, $notes_folder);
echo "<script>
alert('Notes uploaded successfully');
window.location.href='eventnews.php';
</script>";
} else {
echo "<script>
alert('failed to upload notes');
window.location.href='eventnews.php';
</script>";
}
}