]> git.sesse.net Git - ccbs/blob - html/do-add-tournament.pl
Fix bug where showing of an empty tournament would crash.
[ccbs] / html / do-add-tournament.pl
1 #! /usr/bin/perl
2
3 use ccbs;
4 use strict;
5 use warnings;
6
7 my $dbh = ccbs::db_connect();
8 my $cgi = new CGI;
9
10 my $season = $cgi->param('season');
11 my $name = $cgi->param('name');
12 my $country = $cgi->param('country');
13 my $place = $cgi->param('place');
14 my $date = $cgi->param('date');
15 my $machine = $cgi->param('machine');
16 my $scoringsystem = $cgi->param('scoringsystem');
17
18 if ($date !~ /^ ( \d{4} - \d\d - \d\d ) $/x) {
19         ccbs::user_error("Ugyldig dato (må være på formen YYYY-MM-DD).");
20 }
21
22 $dbh->do('INSERT INTO tournaments (season, tournamentname, country, location, date, machine, scoringsystem) VALUES (?,?,?,?,?,?,?)',
23         undef, $season, $name, $country, $place, $date, $machine, $scoringsystem);
24
25 ccbs::print_header();
26 ccbs::process_template('do-add-tournament.tmpl', 'Legg til turnering', {});
27
28 $dbh->disconnect;