-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsentAction.php
More file actions
executable file
·44 lines (38 loc) · 1.35 KB
/
ConsentAction.php
File metadata and controls
executable file
·44 lines (38 loc) · 1.35 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
<?php
require __DIR__ . '/GetTargetUrl.php';
require __DIR__ . '/Credentials.php';
// Check that the Checkbox has been checked and return if not
if (!isset($_POST['Checkbox']) || ($_POST['Checkbox'] != 'Check')) {
die('Consent not granted.');
}
// Connect to the database
$Conn = new mysqli($Servername, $Username, $Password, $Dbname);
if ($Conn->connect_error) {
die("Database connection failed: " . $Conn->connect_error);
}
// Unpack the inputs
$SubjectId = $_POST['SubjectId'];
$Initials = $_POST['Initials'];
$SubjectId = mysqli_real_escape_string($Conn, $SubjectId);
$Initials = mysqli_real_escape_string($Conn, $Initials);
$Now = new DateTimeImmutable("now", new DateTimeZone('Europe/London'));
$DateTime_Consent = $Now->format('Y-m-d\TH:i:s');
// Update the Register table
$Sql00 = "UPDATE Register SET
State = 1, DateTime_Consent = '$DateTime_Consent'
WHERE SubjectId = '$SubjectId'";
if ($Conn->query($Sql00) == false) {
die("Query Sql0 failed to execute successfully!");
}
// Add to the ConsentLog table
$Sql01 = "CALL RecordConsentLog(
'$SubjectId', '$Initials', '$DateTime_Consent')";
if ($Conn->query($Sql01) == false) {
$Conn->close();
die("Query Sql1 failed to execute successfully!");
}
// Close the database connection and redirect
$Url = GetTargetUrl($Conn, $SubjectId);
$Conn->close();
header('Location: ' . $Url);
exit();