sub exec_add_sql { my $id= $in{'id'}; my $title = $in{'title'}; my $date = $in{'date'}; my $description = $in{'description'}; my $category = $in{'category'}; # connect to the database my $dbh = DBI->connect("DBI:mysql:database:sql.server.com", user, pw); #prepare the query my $sth = $dbh->prepare("insert into postcards(id, title, date, description, category) values('$id', '$title', '$date', '$description', '$category')"); # execute the query $sth->execute(); $sth->finish(); $dbh->disconnect(); }