-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsert.php
More file actions
100 lines (76 loc) · 1.87 KB
/
insert.php
File metadata and controls
100 lines (76 loc) · 1.87 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
<?php
session_start();
include('connect.php');
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Insert PDF</title>
<style media="screen">
div {
border: 2px solid black;
width: 500px;
margin-left: 370px;
margin-top: 50px;
padding: 30px;
}
form {
margin-left: 70px;
}
label {
font-size: 25px;
font-weight: bold;
}
#pdf {
font-size: 20px;
font-weight: bold;
margin-top: 10px;
}
#upload {
font-size: 20px;
font-weight: bold;
margin-left: 100px;
}
</style>
</head>
<body>
<?php
if($_SESSION['teacherID'] != NULL){
?>
<div class="">
<form class="" action="insert.php" method="post" enctype="multipart/form-data">
<label for="">Choose Your PDF File</label><br>
<input id="pdf" type="file" name="pdf" value="" required><br><br>
<input id="upload" type="submit" name="submit" value="Upload">
<?php
if (isset($_POST['submit'])) {
$pdf=$_FILES['pdf']['name'];
$pdf_type=$_FILES['pdf']['type'];
$pdf_size=$_FILES['pdf']['size'];
$pdf_tem_loc=$_FILES['pdf']['tmp_name'];
$pdf_store="pdf/".$pdf;
$mail = $_SESSION['mail'];
move_uploaded_file($pdf_tem_loc,$pdf_store);
$sql="INSERT INTO pdf_file(pdf, mail) values('$pdf', '$mail')";
$query=mysqli_query($conn,$sql);
echo "<script>window.location.href='teacherProfile.php'</script>";
}
?>
</form>
</div>
<?php
}
else
{
?>
<script>
alert("Error. Login Required");
</script>
<?php
echo "<script>window.location.href='index.php?'</script>";
}
?>
</body>
</body>
</html>