-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
116 lines (102 loc) · 3.87 KB
/
home.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php session_start();
include("header.php");
include("db.php");
// to disable back after logged out
if(!isset($_SESSION['logged_in']))
echo "<script>window.location.href='index.php';</script>";
?>
<div class="container">
<h2><center><b>Home<b></center> </h2>
<div class="panel panel-default">
<div class="panel-body">
<!--------------------------------to make schedule if schedule table is empty------------------------------------------->
<?php
//if schedule is not mae then promt user to make schedule
$selectresult = mysqli_query($con,"select * FROM schedule ");
if(mysqli_num_rows($selectresult)<=0)
{
?>
<h3>
<center>
<p> Schedule table is empty. Click below to make schedule</p>
<a href="schedule.php" class="btn btn-primary btn-lg">Make Schedule</a>
</center>
</h3>
<?php
}
//if schedule is not mae then promt user to make schedule
?>
<!--------------------------------to make schedule if schedule table is empty------------------------------------------->
<div class="well text-center">
<center><h3>Welcome <?php echo strtoupper($_SESSION['name']); ?> <br></h3><h4> <?php echo strtoupper($_SESSION['subject']); ?></h4></center>
<h4>Date: <?php echo date("d-m-Y"); ?></h4> </div>
<!----------------------------------------------------------------->
<p>Click on your subject to take attendance</p><br><bt>
<table class="table table-stripped">
<tr>
<th>WEEK</th> <th>PERIOD 1</th> <th>PERIOD 2</th> <th>PERIOD 3</th><th>PERIOD 4</th> <th>PERIOD 5</th> <th>PERIOD 6</th>
</tr>
<?php
//weekname for getting todays schedule
$weekname= date('l', strtotime(date("d-m-Y")));
$result=mysqli_query($con,"select * from schedule where week= '$weekname' ;");
if(mysqli_num_rows($result)<=0)
{
echo "<script>alert('You have no class!');</script>";
session_destroy();
echo "<script>window.location.href='index.php';</script>";
}
$row=mysqli_fetch_array($result)
?>
<tr>
<th><?php echo $row['week']; ?> </th>
<td >
<!-----------if is for disabling the button if not their period else part is for storing period to enter in attendance table----------->
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="1">
<input type="submit" value="<?php echo $row['period1']; ?>"
<?php if ($row['period1'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
<td>
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="2">
<input type="submit" value="<?php echo $row['period2']; ?>"
<?php if ($row['period2'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
<td>
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="3">
<input type="submit" value="<?php echo $row['period3']; ?>"
<?php if ($row['period3'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
<td>
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="4">
<input type="submit" value="<?php echo $row['period4']; ?>"
<?php if ($row['period4'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
<td>
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="5">
<input type="submit" value="<?php echo $row['period5']; ?>"
<?php if ($row['period5'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
<td>
<form method="POST" action="take_attendance.php">
<input type="hidden" name="period" value="6">
<input type="submit" value="<?php echo $row['period6']; ?>"
<?php if ($row['period6'] != $_SESSION['subject']) echo "Disabled"; ?> />
</form>
</td>
</tr>
</table>
</div>
</div>
</div>
<!--container-->
</div>