Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/aviral/aviral/
Upload File :
Current File : /var/www/html/venkat/aviral/aviral/rem.php

<?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;
?>