Additional adjustments to configuration saving
authorBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 05:41:58 +0000 (01:41 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 05:41:58 +0000 (01:41 -0400)
configure.php

index 584c787..6b85a43 100755 (executable)
@@ -25,26 +25,30 @@ if( isset($_POST) )
     $attribute = $id[1];
     $setting = $id[2];
     $value = $_POST[$key];
+    if($value == "on")
+      $value = 1;
 
-    
-    $params = array(':host' => $host, 
+    if( $attribute != "" )
+    {
+      $params = array(':host' => $host, 
                     ':attribute' => $attribute, 
                     ':setting' => $setting, 
                     ':value' => $value);
         
-    $insert = "INSERT INTO bdsmweb(host, attribute) ".
+      $insert = "INSERT INTO bdsmweb(host, attribute) ".
               "VALUES (:host, :attribute);";
-    $stmt = $db->prepare($insert);
+      $stmt = $db->prepare($insert);
 
-    if( $stmt )
-      $stmt->execute($params);
+      if( $stmt )
+        $stmt->execute($params);
       
-    $update = "UPDATE bdsmweb SET :setting = :value ".
-              "WHERE host = :host AND attribute = :attribute;";
-    $stmt = $db->prepare($update);
+      $update = "UPDATE bdsmweb SET :setting=:value ".
+              "WHERE host=:host AND attribute=:attribute;";
+      $stmt = $db->prepare($update);
       
-    if( $stmt )
-      $stmt->execute($params);
+      if( $stmt )
+        $stmt->execute($params);
+    }
   }
 }
 ?>