read.php 530 B

12345678910111213141516171819202122232425
  1. <?php
  2. include '../connection.php';
  3. try {
  4. $key = $_POST['key'];
  5. $statement = $db->prepare("select value from config where key = '$key'");
  6. if(!$statement->execute()) {
  7. throw new Exception(implode(', ', $statement->errorInfo()));
  8. }
  9. $jsonResult = array(
  10. 'success' => true,
  11. 'value' => $statement->fetch(PDO::FETCH_COLUMN)
  12. );
  13. } catch(Exception $e) {
  14. $jsonResult = array(
  15. 'success' => false,
  16. 'message' => $e->getMessage()
  17. );
  18. }
  19. echo json_encode($jsonResult);
  20. ?>