#! /usr/bin/perl

use ccbs;
use strict;
use warnings;

ccbs::admin_only();

my $dbh = ccbs::db_connect();
my $cgi = new CGI;

my $tournament = $cgi->param('tournament');
my $nick = $cgi->param('nick');
my $country = $cgi->param('country');
my $club = $cgi->param('club');

$club = undef if ($club == -1);

$dbh->do('INSERT INTO players (nick, country, club) VALUES (?, ?, ?)', undef, $nick, $country, $club);
my $ref = $dbh->selectrow_hashref('SELECT player FROM players WHERE nick=?',
	undef, $nick);

ccbs::print_see_other('registration.pl?id=' . $tournament . '&player=' .
	$ref->{'player'});

$dbh->disconnect;
