source: trunk/npemap.org.uk/perllib/NPEMap.pm @ 236

Last change on this file since 236 was 236, checked in by Dominic Hargreaves, 14 years ago

Add print_html_err to library

File size: 765 bytes
Line 
1package NPEMap;
2
3use vars qw(@ISA @EXPORT);
4use warnings;
5use strict;
6
7use vars qw($dbname $dbhost $dbuser $dbpass);
8
9use NPEMap::Config;
10
11require Exporter;
12@ISA    = qw(Exporter);
13@EXPORT = qw(setup_dbh print_html_err);
14
15sub setup_dbh {
16    my $data_source = "dbi:Pg:dbname=$dbname";
17    $data_source .= ";host=$dbhost" if $dbhost;
18    return DBI->connect_cached($data_source, $dbuser, $dbpass);
19}
20
21sub print_html_err($$) {
22    my $err = shift;
23    my $returnlink = shift;
24    print "Content-type: text/html\n\n";
25    print "<html><head><title>Error submitting</title></head>\n";
26    print "<body><p>The following error occurred whilst submitting data:\n";
27    print CGI::escapeHTML($err);
28    print "</p><p>$returnlink</p>\n";
29    print "</body></html>\n";
30}
31
321;
Note: See TracBrowser for help on using the repository browser.