Listing 3: add-category.html %# -*- mmm-classes: mason -*- % if ($successful_insert) {
The category "<% $new_category_name %>" was added successfully.
% } else {The category "<% $new_category_name %>" was not added successfully. Error message:
<% $DBI::errstr %>% } <%once> my $dbh; %once> <%init> # Connect to the database, if we haven't already done so $dbh = $m->comp("database-connect.comp"); # Now insert the new category my $sql = "INSERT INTO Categories "; $sql .= " (category_name) "; $sql .= "VALUES "; $sql .= " (?) "; my $sth = $dbh->prepare($sql); my $successful_insert = $sth->execute($new_category_name); %init> <%args> $new_category_name %args>