Commit 49c1a356 authored by KYC's avatar KYC

StartTijd - Eindtijd check

parent a97ba38d
...@@ -39,6 +39,7 @@ function checkSet($inputFieldsCount, $inputFields) { ...@@ -39,6 +39,7 @@ function checkSet($inputFieldsCount, $inputFields) {
} }
if(empty($_POST['getActivityID']) == FALSE){ if(empty($_POST['getActivityID']) == FALSE){
if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
$activityID = $_POST['getActivityID']; $activityID = $_POST['getActivityID'];
if (empty($_POST['activiteit']) == FALSE && sanityCheck($_POST['activiteit'], 'string', 80) != FALSE) { if (empty($_POST['activiteit']) == FALSE && sanityCheck($_POST['activiteit'], 'string', 80) != FALSE) {
...@@ -88,9 +89,9 @@ if(empty($_POST['getActivityID']) == FALSE){ ...@@ -88,9 +89,9 @@ if(empty($_POST['getActivityID']) == FALSE){
echo '<p ' . $redTextError . '>Uw opmerking bevat ' . strlen($_POST['opmerking']) .' karakters</p>'; echo '<p ' . $redTextError . '>Uw opmerking bevat ' . strlen($_POST['opmerking']) .' karakters</p>';
echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>'; echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>';
} }
// check if it has 1 or more errors, if so run exit() // check if it has 1 or more errors, if so run exit()
if ($errors >= 1) { if ($errors >= 1) {
$errors = 0;
exit(); exit();
} }
...@@ -124,6 +125,10 @@ if(empty($_POST['getActivityID']) == FALSE){ ...@@ -124,6 +125,10 @@ if(empty($_POST['getActivityID']) == FALSE){
} }
mysqli_close($conn); mysqli_close($conn);
} else {
// Default message if the form is POSTed without a single value
echo '<p ' . $redTextError . '>Vul alstublieft alle velden in</p>';
}
} }
else{ else{
// checks if all inputFields variables are not empty // checks if all inputFields variables are not empty
...@@ -168,7 +173,7 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) { ...@@ -168,7 +173,7 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
} }
// check the POST variable Comment is correct // check the POST variable Comment is correct
if (sanityCheck($_POST['opmerking'], 'string', 80) != FALSE) { if (strlen($_POST['opmerking']) < 80) {
$comment = $_POST['opmerking']; $comment = $_POST['opmerking'];
} else { } else {
...@@ -177,8 +182,23 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) { ...@@ -177,8 +182,23 @@ if (checkSet($inputFieldsCount, $inputFields) != FALSE) {
echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>'; echo '<p ' . $redTextError . '>Het maximaal aantal karakters is 80.</p>';
} }
$selectQuery = "SELECT StartTime, EndTime, Activity, Day FROM Leefpatroon WHERE OuderID = '$OuderID'";
$result = $conn->query($selectQuery);
while ($row = $result->fetch_assoc()) {
// if StartTime is the same as another activity's one on the same day, exit
if ($startTime == $row["StartTime"] && $day == $row["Day"]) {
$errors++;
echo '<p ' . $redTextError . '>Er is al een activiteit geregistreerd op dezelfde Begintijd voor (' . $row["Activity"] . ').</p>';
// if StartTime is during another activity on the same day, exit
} else if ($row["StartTime"] < $startTime && $row["EndTime"] > $startTime && $day == $row["Day"]) {
$errors++;
echo '<p ' . $redTextError . '>Een andere activiteit is al geregistreerd om gemonitord te worden tijdens uw opgegeven Begintijd (' . $row["Activity"] . ').</p>';
}
}
// check if it has 1 or more errors, if so run exit() // check if it has 1 or more errors, if so run exit()
if ($errors >= 1) { if ($errors >= 1) {
$errors = 0;
exit(); exit();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment