Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/venkat/aviral/aviral/ |
<?php
include('db1.php');
include('session.php');
include('get_course.php');
?>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<center>
<?php
$id = addslashes($_SESSION['key']);
$_backButton = '<div class="container"><form action="register.php"><button type="submit">Go Back</button></form></div>';
if (!isset($_POST['del'])) {
echo '<h4>No choices selected.</h4>';
echo $_backButton;
exit;
}
$courses = $_POST['del'];
$q = $conn->prepare("select course_id from aviral_registered where student_id=:id");
$q->bindValue(":id", $id);
$q->execute();
$res = $q->fetchAll(PDO::FETCH_ASSOC);
foreach ($res as $row) {
$courseid = $row['course_id'];
if (in_array($courseid, $courses)) {
// if course in registered is specified for deletion
$q = $conn->prepare("delete from aviral_registered where student_id = :id and course_id = :courseid");
$q->bindValue(":id", $id);
$q->bindValue(":courseid", $courseid);
$q->execute();
$course = get_course($conn, $courseid);
if ($q->rowCount() == -1) {
echo 'ERR: Unable to un-register course: ' . $course['course_name'] . '<br>';
} else {
echo 'Un-registered course: ' . $course['course_name'] . '<br>';
}
}
}
echo $_backButton;
?>