From: Brian Flowers Date: Tue, 27 Sep 2016 05:30:32 +0000 (-0400) Subject: Bugfixes on configuration saving X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=9285724cc7c8f89665283b3b10797b211ab6cc2b;p=bdsm-web.git Bugfixes on configuration saving --- diff --git a/configure.php b/configure.php index 34e2d31..5fd29bb 100755 --- a/configure.php +++ b/configure.php @@ -26,20 +26,31 @@ if( isset($_POST) ) $setting = $id[2]; $value = $_POST[$key]; - $query = "INSERT INTO bdsmweb(host, attribute, $setting) ". - "VALUES (:host, :attribute, :value);"; - $stmt = $db->prepare($query); + + $params = array(':host' => $host, + ':attributes' => $attributes, + ':setting' => $setting, + ':value' => $value) + + $insert = "INSERT INTO bdsmweb(host, attribute) ". + "VALUES (:host, :attribute);" + $stmt = $db->prepare($insert); - if( !$stmt ) + if( $stmt ) { - print_r($db->errorInfo()); + $stmt->bindParam($params); + $stmt->execute(); + } + + $update = "UPDATE bdsmweb SET :setting = :value ". + "WHERE host = :host AND attribute = :attribute;"; + $stmt = $db->prepare($update); + + if( $stmt ) + { + $stmt->bindParam($params); + $stmt->execute(); } - - $stmt->bindParam(':host', $host); - $stmt->bindParam(':attribute', $attribute); - $stmt->bindParam(':value', $value); - - $stmt->execute(); } } ?> @@ -119,7 +130,6 @@ if( isset($_POST) ) query("SELECT DISTINCT host FROM MEASUREMENTS"); -print_r($db->errorInfo()); $hosts = Array(); while( $host = $result->fetch() ) @@ -144,7 +154,7 @@ foreach ($hosts as $host) echo " "; echo " $attribute"; echo " "; - echo " "; + echo " "; echo " - ". ""; echo " ";