-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_get_attendance.php
132 lines (86 loc) · 3.23 KB
/
update_get_attendance.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
session_start();
$posted = array();
$att_array = array();
$name_array = array();
$roll_array = array();
/*$day = date('d');
$month = date('m');
$year = date('Y');*/
if(isset($_SESSION['username']) && isset($_SESSION['password']))
{
$day = $_SESSION['day'];
$month = $_SESSION['month'];
$year = $_SESSION['year'];
$name_array = $_SESSION['name_array'];
$roll_array = $_SESSION['roll_array'];
foreach ($_SESSION['radioKeys'] as $radioKey) {
# code...
if (isset($_POST[$radioKey])) {
$posted[$radioKey] = $_POST[$radioKey];
}
}
$_SESSION['radio'] = $posted;
foreach ($_SESSION['radio'] as $radioKey => $radioValue)
{
//var_dump($radioValue);
$att_array[] = $radioValue;
}
if (!empty($name_array) && !empty($roll_array) && !empty($att_array) && !empty($day) && !empty($month) && !empty($year) ) {
$host_name = 'localhost';
$user = 'root';
$password = '';
$database = 'attendance';
$connection = mysqli_connect($host_name,$user,$password,$database);
if ($connection) {
//echo "Connected to the DB <br>";
# code...
}
else
{
echo "Not Connected".mysqli_error($connection);
}
$name_values = array();
$roll_values = array();
$att_values = array();
if ($_SESSION['class'] == 'class10') {
foreach ($name_array as $key => $name_values) {
$name_values = mysqli_real_escape_string($connection,$name_values);
$roll_values = mysqli_real_escape_string($connection,$roll_array[$key]);
$att_values = mysqli_real_escape_string($connection,$att_array[$key]);
echo $name_values."<br>";
echo $att_values."<br>";
echo $roll_values."<br>";
$sql= "UPDATE `aclass10` SET Name='".$name_values."',attendance='".$att_values."',RollNo='".$roll_values."',day='".$day."',month='".$month."',year='".$year."'WHERE RollNo='".$roll_values."'";
$result = mysqli_query($connection,$sql);
}
# code...
}
if ($_SESSION['class'] == 'class12') {
foreach ($name_array as $key => $name_values) {
$name_values = mysqli_real_escape_string($connection,$name_values);
$roll_values = mysqli_real_escape_string($connection,$roll_array[$key]);
$att_values = mysqli_real_escape_string($connection,$att_array[$key]);
echo $name_values."<br>";
echo $att_values."<br>";
echo $roll_values."<br>";
$sql= "UPDATE `aclass12` SET Name='".$name_values."',attendance='".$att_values."',RollNo='".$roll_values."',day='".$day."',month='".$month."',year='".$year."'WHERE RollNo='".$roll_values."'";
$result = mysqli_query($connection,$sql);
}
# code...
}
if($result)
{
echo "Attendance Succesfully added";
}
else
{
echo "Data Not added".mysqli_error($connection);
}
}
}
else
{
require 'redirect_login.php';
}
?>