-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
161 lines (137 loc) · 5.29 KB
/
home.php
File metadata and controls
161 lines (137 loc) · 5.29 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="Homecss.css?<?= time()?>">
<script src="http://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link href="https://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css" rel="stylesheet">
<title>Home</title>
<style type="text/css">
.ap-btn {
margin-top: 100px;
/* background-color: #f15757; */
background-color: white;
font-family:Algerian;
color: black;
padding: 18px 20px;
/*border: none;*/
border: 2px solid red;
border-radius: 15px;
cursor: pointer;
/* width: 100%; */
/* opacity: 0.9; */
letter-spacing: 1px;
font-size: 18px;
text-transform: uppercase;
transition: 0.3s ease;
position: relative;
/*margin-right: 10px; */
}
.ap-btn:hover{
background-color: #f44336;
color: white;
}
</style>
<?php
date_default_timezone_set('Asia/Kolkata');
?>
<?php
session_start();
if(!isset($_SESSION['rollNo'])) {
header('location: Login.php');
}
// Connection
//$conn= mysqli_connect('localhost', 'root', '','leave');
include_once('connection.php');
/*$session_roll = $_SESSION['rollNo'];
$sql1 = "SELECT l_status FROM apply WHERE rollno=$session_roll";
$result1 = mysqli_query($conn, $sql1);
if(mysqli_num_rows($result1) > 0) {
$row = mysqli_fetch_assoc($result1);
// print_r($_SESSION);
// print_r($row);
$l_status = $row['l_status'];
} else {
$l_status = "Unknown";
echo "<script>console.log('No roll No')</script>";
}
if (!$conn) {
echo "Connection failed: " . mysqli_connect_error();
}
if(isset($_POST['apply'])) {
$roll = htmlspecialchars($_SESSION['rollNo']);
$type = htmlspecialchars($_POST['passtype']);
$from = htmlspecialchars($_POST['from']);
$to = htmlspecialchars($_POST['to']);
$reason = htmlspecialchars($_POST['reason']);
$sql = "INSERT INTO apply(rollno, leavetype, l_from, l_to, reason) VALUES({$roll}, '{$type}', '{$from}', '{$to}', '{$reason}')";
if(mysqli_query($conn, $sql)) {
echo "<script>window.alert('Applied')</script>";
// $_SESSION["rollno"] = $name;
header("location: success.html");
} else {
echo "<script>window.alert('Error');</script>";
}
}
// print_r($_SESSION);
*/
$roll_no = $_SESSION['rollNo'];
$student_id = $_SESSION['student_id'];
$today_date = date("Y-m-d");
$attendance_status = 'Unknown';
$sql_select = "SELECT * FROM student_attendance WHERE roll_no='$roll_no' AND date='$today_date'";
$result = mysqli_query($conn, $sql_select);
if (mysqli_num_rows($result) > 0) {
$attendance_status = 'Marked for today';
}
if (isset($_POST['apply'])) {
$roll_no = $_SESSION['rollNo'];
$student_id = $_SESSION['student_id'];
$today_date = date("Y-m-d");
$sql_select = "SELECT * FROM student_attendance WHERE roll_no='$roll_no' AND date='$today_date'";
$result = mysqli_query($conn, $sql_select);
if (mysqli_num_rows($result) > 0) {
echo "<script>alert('Your Attendance has been already marked');window.location.href='home.php';</script>";
} else {
$sql_insert = "INSERT INTO student_attendance(student_id, roll_no, date) VALUES ($student_id, '$roll_no', '$today_date')";
if (mysqli_query($conn, $sql_insert)) {
echo "<script>alert('Your Attendance has been marked sucessfully');window.location.href='home.php';</script>";
} else {
echo "<script>alert('Something went wrong');window.location.href='home.php';</script>";
}
}
}
?>
</head>
<body>
<form action="Login.php" method="post">
<div class="field btns">
<input class="ap-btn" type="button" onclick="BalFunc()" id="BalButton" name="sample" value="Attendance Summary"><br>
<input class="ap-btn" type="button" onclick="StatusFunc()" id="StatusButton" name="sample" value="<?= $attendance_status ?>"><br>
<!--<input class="ap-btn" type="button" name="sample" value="Edit Profile"><br>-->
<!-- <input class="ap-btn" type="button" name="sample" value="Logout"> -->
</div>
<input class="ap-btn" type="submit" name="logout" value="Logout">
</form>
<div class="container">
<header>Attendance Form</header>
<div class="form-outer">
<form action="home.php" method="post">
<div class="page ">
<span>Welcome, <b><?= $_SESSION['name'] ?></b></span><br><br>
<p>Roll No: <b><?= $_SESSION['rollNo'] ?></b></p><br>
<div class="field btns">
<button class="apply" type="submit" name="apply">Mark Attendance</button>
</div>
</div>
</form>
</div>
</div>
<script>
function BalFunc() {
window.location.href = 'att_summary.php';
}
</script>
</body>
</html>