I've tried to create a program that allows the user to input a time/duration (hh:mm). If this time/duration exceeds one hour, then 15 minutes are added to a variable called 'MaintenanceDuration'. If their input is less than or equal to an hour, 10 minutes are added.
When I run the code it only ever adds 10 minutes, despite the input being greater than an hour.
I've been told its because $Duration
is not set/defined however surely it is when the user submits their input?
HTML:
<html>
<body>
<form action="maintenance-formula.php" method="post">
Duration: <input type="time" name="Duration" id="Duration"><br>
<input type="submit">
</form>
</body>
</html>
PHP:
<?php
$Duration = $_POST['Duration'];
if ($Duration > strtotime('1:00:00')) {
echo "Added 15 maintenance minutes!";
$MaintenanceDuration = strtotime('0:15:00');
} else {
echo "Added 10 maintenance minutes!";
$MaintenanceDuration = strtotime('0:10:00');
}
$MaintenanceDuration = strftime('%H:%M', $MaintenanceDuration);
echo $MaintenanceDuration;
?>
Any help would be greatly appreciated.