-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropcourse.php
69 lines (57 loc) · 1.62 KB
/
dropcourse.php
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
<?php
session_start();
#echo $_SESSION['stud_id']; #works
$host='localhost';
include 'rootpass.php';
$db='Moodle';
$con=mysqli_connect($host,$user,$pass,$db);
if (!$con){
echo "Couldn't connect Database.";
}
#echo "Database ".$db." Connected successfully\n";
#$sql='SELECT stud_id,name,stud_psswd,course_picked,time_picked,course_removed,time_removed from studs';
#$retval=mysqli_query($con,$sql);
?>
<html>
<head><title>Drop Courses</title> </head>
<body>
<h1>Drop Courses</h1>
<p>These are the list of your currently enrolled courses</p>
<?php
$name=$_SESSION['name'];
$id=$_SESSION['stud_id'];
$name=$_SESSION['name'];
$pass=$_SESSION['password'];
$coursepick=$_SESSION['course_picked'];
$timepick=$_SESSION['time_picked'];
$sql="SELECT course_picked from studs where name='$name'";
$retval=mysqli_query($con,$sql);
while($row=mysqli_fetch_assoc($retval)){
$currcourse=$row['course_picked'];
if ($currcourse){
echo "--> $currcourse<br><br>";
if ($_POST['delcourse']==$currcourse && $_POST['delcourse']==True){
$newdel=$_POST['delcourse'];
$deltime=time();
$sql="delete from studs where '$newdel'=course_picked and name='$name'";
#$sql="Insert into studs values($id,'$pass','$name','$newadd','$addtime',NULL,NULL)";
#$sql="UPDATE studs "."SET course_picked='$newadd',time_picked='$addtime' "."WHERE name='$name'";
$ret2=mysqli_query($con,$sql);
if(newdel){
echo "$newdel has been dropped.";
}
}
else{
continue;
}
}
}
?>
<br>
<form action="<?php $_PHP_SELF ?>" method="POST">
<input type="text" name="delcourse">
<input type="submit" value="Confirm">
</form>
<a href="\Moodle\studwelcome.php"><p align='right'>Go Back</p></a>
</body>
</html>