SIMPLICITY_Bug-189_Course_Delete_btn #2

Merged
mrlan merged 10 commits from SIMPLICITY_Bug-189_Course_Delete_btn into master 2021-07-21 19:24:34 +08:00
2 changed files with 87 additions and 1 deletions

View File

@ -99,6 +99,92 @@ if( $_SESSION['user_type'] == "Student")
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#menu4">Marked</a> <a class="nav-link" data-toggle="tab" href="#menu4">Marked</a>
</li> </li>
<!----------Delete Course Button----------->
<li>
<html>
<body>
<div class="modal fade" id="delcourse">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Please confirm!</h2>
<button type="button" class="close red" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<p>Are you sure about deleting this course? This action can not be reversed!</p>
</div>
<div class="modal-footer">
<form method="POST" action="">
<button type="button" class="btn action-button blue" data-dismiss="modal">Cancel</button>
<input type="submit" name="submit" class="btn action-button red" value="Delete"/>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<button type="button" class="btn action-button red" data-toggle="modal" data-target="#delcourse">Delete Course</button>
</div>
</div>
</div>
</div>
<?php
// Connect to MySQL database
$con = mysqli_connect("localhost", $mysql_username, $mysql_password, "lrr");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['submit'])){
header("Location: Courses.php");
$result = mysqli_query($con, "DELETE FROM course_students_table WHERE Course_ID='$course_id'");
}
?>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<style>
/*--------------------[ Delete Course Button ]*/
.action-button {
font-family: 'Pacifico', cursive;
font-size: 18px;
color: #FFF;
text-decoration: none;
}
.red {
background-color: #E74C3C;
border-bottom: 5px solid #BD3E31;
text-shadow: 0px -2px #BD3E31;
}
.blue {
background-color: #4d4dff;
border-bottom: 5px solid #4d4dff;
text-shadow: 0px -2px #4d4dff;
}
</style>
</body>
</html>
</li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">

View File

@ -23,7 +23,7 @@ $time = time();
if ( (isset($_SESSION["user_student_id"]) && strpos($file, $_SESSION["user_student_id"])) || $_SESSION['user_type'] == "Lecturer" || $_SESSION['user_type'] == "TA") { if ( (isset($_SESSION["user_student_id"]) && strpos($file, $_SESSION["user_student_id"])) || $_SESSION['user_type'] == "Lecturer" || $_SESSION['user_type'] == "TA") {
// 发送文件头部 // 发送文件头部
header("Content-type: $type"); header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename"); header('Content-Disposition: attachment;filename="'.urldecode($filename).'"');
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache'); header('Pragma: no-cache');
header('Expires: 0'); header('Expires: 0');