-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_page.php
More file actions
160 lines (126 loc) · 5.24 KB
/
Copy pathsubmit_page.php
File metadata and controls
160 lines (126 loc) · 5.24 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
<?php
include 'inc/session.php';
// if ($row['class'] != 1 && $row['class'] != 2) {
// header('location: index.php');
// }
$msg = $name = $class = $comments = "";
if (isset($_POST['submit'])) {
$id = $_SESSION['id'];
$class = $_SESSION['class'];
$project = mysqli_real_escape_string($connect, $_POST['project']);
$comments = mysqli_real_escape_string($connect, $_POST['comments']);
$time = date('h:i:sa d/M/Y');
$file = $_FILES['file']['name'];
$tmp = $_FILES['file']['tmp_name'];
$type = pathinfo("upload/$file", PATHINFO_EXTENSION);
$sel = "SELECT * FROM submissions WHERE name = '$id' && project ='$project'";
$ins = mysqli_query($connect, $sel);
$count = mysqli_num_rows($ins);
if ($count > 0) {
$msg = "<div class='text-danger text-center '>You have already Submitted. Contact Your Instructor for assistance</div>";
}
else{
$selr = "SELECT * FROM submissions WHERE file = '$file'";
$insr = mysqli_query($connect, $selr);
$countr = mysqli_num_rows($insr);
if ($countr > 0) {
$msg = "<div class='text-danger p-3 font-weight-bold rounded mb-3 text-center'>File name is already existing. Consider changing the file's name</div>";
}
elseif ($type != "zip" && $type != "docx" && $type != "doc" && $type != "pdf" && $type != "pptx" && $type != ".xlsx") {
$msg = "<div class='text-danger p-3 font-weight-bold rounded mb-3 text-center'>File type must be either zip, pdf, microsoft word file, powerpoint file or excel file.</div>";
}
elseif ($_FILES["file"]["size"] > 2000000) {
// 2mb
$msg = "<div class='text-danger p-3 font-weight-bold rounded mb-3 text-center'>File size is larger than 2mb</div>";
}
elseif ($project == "Select Project Type" ) {
$msg = "<div class='text-danger p-3 font-weight-bold rounded mb-3 text-center'>Select Your Project Type</div>";
}
else{
$sql = "INSERT INTO submissions(name, class, project, file, comments, date) VALUES('$id', '$class', '$project', '$file', '$comments', '$time')";
$query = mysqli_query($connect, $sql);
move_uploaded_file($tmp, "submission_folder/$file");
if ($query) {
header('location: projects');
}
else{
$msg = "<div class='alert-primary p-2 font-weight-bold rounded mb-3 text-center'>Error</div>";
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'inc/link.php'; ?>
<title>Submission Page | Fidelity Portal</title>
</head>
<?php include 'inc/sidebar.php'; ?>
<h6>
<div class="text-center p-2 bg-white">
<div id="typed-strings">
<span>Asalam Alaekun</span>\
<p>Submit Your Projects Here</p>
<p style="font-size: 10px">File type must be either zip, pdf, microsoft<br> word file, powerpoint file or excel file</p>
<p>It must be less than 2mb</p>
<p>Wishing You Success!</p>
<span>Asalam Alaekun</span>\
<p>Submit Your Projects Here</p>
<p style="font-size: 10px">File type must be either zip, pdf, microsoft<br> word file, powerpoint file or excel file</p>
<p>It must be less than 2mb</p>
<p>Wishing You Success!</p>
<span>Asalam Alaekun</span>\
<p>Submit Your Projects Here</p>
<p style="font-size: 10px">File type must be either zip, pdf, microsoft<br> word file, powerpoint file or excel file</p>
<p>It must be less than 2mb</p>
<p>Wishing You Success!</p>
<span>Asalam Alaekun</span>\
<p>Submit Your Projects Here</p>
<p style="font-size: 10px">File type must be either zip, pdf, microsoft<br> word file, powerpoint file or excel file</p>
<p>It must be less than 2mb</p>
<p>Wishing You Success!</p>
</div>
<span id="typed" style="white-space:pre;"></span>
</div>
</h6>
<div class=" ">
<?php echo $msg; ?>
<form method="post" enctype="multipart/form-data" class="p-2">
<label class="font-weight-bold mt-3">Project Type</label>
<div class="form-group">
<select name="project" class="form-control">
<option selected="selected">Select Project Type</option>
<?php
$sql = "SELECT * FROM projects WHERE status = 1";
$query = mysqli_query($connect, $sql);
$counter = mysqli_num_rows($query);
if ($counter > 0) {
?>
<?php
while ($rw = mysqli_fetch_array($query)) {
?>
<option value="<?php echo $rw['id']; ?>"><?php echo $rw['project']; ?> <i class="small">(<?php echo $rw['code']; ?>)</i></option>
<?php }}
else{
?>
<option>You have not been authorized to submit any project. Contact Your Instructor.</option>
<?php } ?>
</select>
</div>
<label class="font-weight-bold mt-3">File<i class="small">(Not larger than 2mb)</i></label>
<div class="form-group">
<input type="file" required="required" name="file" accept=".zip,.docx,.doc,.pdf,.xlsx,.pptx" class="form-control" >
</div>
<label class="font-weight-bold mt-3"> Comments</label>
<div class="form-group">
<textarea name="comments" class="form-control" placeholder="Make Your Comments"><?php echo $comments; ?></textarea>
</div>
<button type="<?php if ($counter > 0) {echo "submit";}else{echo "button";} ?>" name="submit" class="btn btn-primary w-100 mt-2">Submit Now</button>
</form>
</div>
<?php include 'inc/footer.php'; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="lib/typed.js" type="text/javascript"></script>
<script src="assets/demos.js"></script>