Changeset 237
- Timestamp:
- Oct 29, 2006, 7:25:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/cgi/bad-postcode.fcgi
r222 r237 16 16 use lib "$FindBin::Bin/../perllib"; 17 17 use NPEMap; 18 19 sub print_err;20 18 21 19 # Set up database handler to try and make sure it's ready for the first … … 42 40 # In case the database went away, make sure we have a connection 43 41 unless ($dbh = setup_dbh()) { 44 print_ err('Error setting up database connection', $returnlink);42 print_html_err('Error setting up database connection', $returnlink); 45 43 next REQUEST; 46 44 } … … 48 46 # Input validation 49 47 unless (defined $cgi->param('postcode')) { 50 print_ err ("Postcode identifier not supplied");48 print_html_err ("Postcode identifier not supplied", $returnlink); 51 49 next REQUEST; 52 50 } … … 55 53 my $sth = $dbh->prepare('SELECT id FROM postcodes WHERE id = ? AND NOT deleted'); 56 54 unless ($sth->execute($cgi->param('postcode'))) { 57 print_ err('Database error when checking for the postcode', $returnlink);55 print_html_err('Database error when checking for the postcode', $returnlink); 58 56 next REQUEST; 59 57 } 60 58 61 59 unless ($sth->rows) { 62 print_ err('A postcode with that identifier does not exist, or has already been deleted.', $returnlink);60 print_html_err('A postcode with that identifier does not exist, or has already been deleted.', $returnlink); 63 61 next REQUEST; 64 62 } … … 74 72 } else { 75 73 print STDERR "DB error: " . $dbh->errstr . "\n"; 76 print_ err("Database error when adding your data :(", $returnlink);74 print_html_err("Database error when adding your data :(", $returnlink); 77 75 next REQUEST; 78 76 } … … 81 79 # No more requests to serve, so tidy up 82 80 $dbh->disconnect; 83 84 # Helper routines85 sub print_err($$) {86 my $err = shift;87 my $returnlink = shift;88 print "Content-type: text/html\n\n";89 print "<html><head><title>Error submitting</title></head>\n";90 print "<body><p>The following error occurred whilst submitting data:\n";91 print CGI::escapeHTML($err);92 print "<p>$returnlink</p>\n";93 print "</body></html>\n";94 }
Note: See TracChangeset
for help on using the changeset viewer.