private static function writePalindrome($palindrome) { $reflector = new ReflectionClass(__CLASS__); $parameters = $reflector->getMethod(__FUNCTION__)->getParameters(); $args = []; foreach ($parameters as $parameter) { $args[$parameter->name] = ${$parameter->name}; } log_util::logFunctionStart($args); $pdo = lib_database::connect(); if (!empty($pdo)) { log_util::log(LOG_LEVEL_ERROR, "pdo connection WAS NOT empty"); $stmt = $pdo->prepare("INSERT INTO palindromes (string, isPalindrome) VALUE (?, ?, ?)"); $stmt->bindParam(1, $palindrome->getString(), PDO::PARAM_INT); $stmt->bindParam(2, $palindrome->isPalindrome(), PDO::PARAM_STR); $stmt->execute(); } else { log_util::log(LOG_LEVEL_ERROR, "pdo connection WAS empty"); } $pdo = NULL; }
?> ' /></p> <p><input type="submit" name="check-palindrome" value="Check Palindrome" class="button" /></p> </form> <?php $palindromeInput = isset($_POST['palindrome-input']) ? $_POST['palindrome-input'] : NULL; if ($palindromeInput !== NULL) { $isPalindrome = lib_check::palindrome($palindromeInput); if ($isPalindrome) { echo "<p>The given input: '" . $palindromeInput . "' <strong>IS</strong> a palindrome.</p>"; } else { echo "<p class='error'>The given input: '" . $palindromeInput . "' <strong>IS NOT</strong> a palindrome.</p>"; } $palindrome = new Palindrome(NULL, $palindromeInput, $isPalindrome); lib_database::writePalindrome($palindrome); } ?> <!-- ### START Footer ### --> <?php require_once 'inc/footer.php'; ?> <!-- ### END Footer ### --> <!-- ### START Footer ### --> <?php require_once 'inc/footer.php'; ?> <!-- ### END Footer ### --> </div> <!-- ### END Container ### -->