I have a IF Statement where when i submit my page it is going to check if the time exists already and if so assign a value to my variable or echo out a message saying it found the time. Doesnt seem to be working though, i tried == true and !== false but no luck.
Below is code thanks.
$alarm = $_POST[add];
$alarms = explode("\n", shell_exec("crontab -l")); //grab schdules
array_pop($alarms); //remove empty last line
foreach($alarms as $alarm)
if (strpos($alarm, $alarm['alarmhour']) !== false)
$HourSuccess = "Correct";
$message121 = "We found the same time.. ";
The first line defines
$alarm as the value of a value from
$_POST, which is OK.
The foreach line iterates
$alarms with each value being stored to
$alarm, which is also correct. But it will overwrite the original value.
Look at this line:
if(strpos($alarm, $alarm['alarmhour']) !== false)
Don't you think there is a problem using the same variable differently?
Instead, you should probably give a new name to the variable defined on line 1 (e.g.
$postedAlarm), and refactor correct usages in lines below.