-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclockOut.php
32 lines (27 loc) · 878 Bytes
/
clockOut.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
<?php
require_once 'connect.php';
require_once 'functions.php';
if (isLoggedIn()) {
} else {
header('Location: index.php');
die();
}
if(isset($_POST['clockOut'])) {
// $result = mysqli_query($connect, "SHOW TABLE STATUS LIKE 'time_entries'");
// $data = mysqli_fetch_array($result,MYSQLI_ASSOC);
// $next_increment = $data['Auto_increment'];
// echo $next_increment-1;
$time = getdate();
$result = mysqli_query($connect,"SELECT * FROM time_entries WHERE timeOut = 0 AND user_id =".$_SESSION['user_id']."");
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$rowCount = mysqli_num_rows($result);
if ($rowCount == 1) {
$query = "UPDATE time_entries SET timeOut = '".$time['0']."' WHERE id = '".$row['id']."'";
if (mysqli_query($connect, $query)) {
header('Location: index.php');
}
} else {
header('Location: index.php?msg=1');
}
}
?>