-
Notifications
You must be signed in to change notification settings - Fork 0
/
studwelcome.php
77 lines (68 loc) · 2.07 KB
/
studwelcome.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
70
71
72
73
74
75
76
77
<?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);
while($row=mysqli_fetch_assoc($retval)){
if ($_SESSION['stud_id']==($row['stud_id'])){
$_SESSION['name']=($row['name']);
$_SESSION['password']=($row['stud_psswd']);
$name=$_SESSION['name'];
$_SESSION['course_picked']=($row['course_picked']);
$_SESSION['time_picked']=($row['time_picked']);
$_SESSION['course_removed']=($row['course_removed']);
$_SESSION['time_removed']=($row['time_removed']);
}
else{
continue;
}
} #Added all as session variables.
?>
<html>
<head>
<title>Welcome to Moodle</title>
</head>
<body>
<?php
if ($_POST['studdo']){
$path=$_POST['studdo'];
header("Location:$path");
exit();
}
?>
<h1 align='center' font face="Comic Sans MS"><b> Mini Moodle<b></h1>
<p> Here you can check for available courses, drop some courses and also check various messages from professors </p>
<?php
echo "<center>Hello $name!</center><br><br>" ;
echo "These are the courses you are currently studying:<br>";
$sql="SELECT stud_id,stud_psswd,name,course_picked,time_picked,course_removed,time_removed 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>";
}
else{
continue;
}
}
?>
<br>
<br><br>
<form action="<?php $_PHP_SELF ?>" method="POST">
<input type="radio" name="studdo" value="/Moodle/addcourse.php">Add Course<br><br>
<input type="radio" name="studdo" value="/Moodle/dropcourse.php">Drop Course<br><br>
<input type="radio" name="studdo" value="/Moodle/message.php">Check Messages<br><br>
<input type="submit" value="Go!">
</form>
<p align='right'><i> To log out, just close this window</i></p>
</body>
</html>