Time for action – creating a new database item

Creating a new item is done by using an INSERT SQL statement. The following code adds a new item to the Cacti database:

db_execute("
  INSERT INTO `plugin_cbEnhancedInfo_dataTable`
   (`hostId`, `longitude`, `latitude`,`contactAddress`, 
   `additionalInformation`)
  VALUES
   ($s_dataHostId, '$s_dataLongitude','$s_dataLatitude',
   '$s_dataContactAddress','$s_dataAdditionalInformation')
");

If you look into the cbEnhancedInfo_addInformation.php file from Example 5, you will see that this code is actually missing. You can add it right after the comment in the following section:

if ( (isset ($_POST['contactAddress'])) && 
     (isset ($_POST['save_component_import']) ) ) {
   /* Add Save statements here */
}

As you can see, ...

Get Cacti 0.8 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.