num_rows < 1) { error("alarms", "You are not allowed to edit that alarm"); } //Check if stream is allowed $sql = "SELECT `name` FROM `stream` WHERE `dev_id`=$deviceid AND `id`=$stream"; $query = ExecQuery($mysqli, $sql); if($query->num_rows < 1) { error("alarms", "You are not allowed to use that stream"); } //Remove seconds $time = substr($time, 0, 5); //Check time if(!preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $time)) { error("alarms", "Invalid time"); } $time .= ":00"; //Add alarm $sql = "UPDATE `alarm` SET `name`='$name', `time`='$time', `stream`=$stream WHERE `id`=$alarm"; ExecQuery($mysqli, $sql); success("alarms", "The alarm has been updated"); ?>