#!/usr/local/bin/perl
# newdb_form.cgi
# Display a form for creating a new database

require './mysql-lib.pl';
$access{'create'} || &error($text{'newdb_ecannot'});
&header($text{'newdb_title'}, "", "newdb_form");
print "<hr>\n";

print "<form action=newdb.cgi>\n";
print "<table border>\n";
print "<tr $tb> <td><b>$text{'newdb_header'}</b></td> </tr>\n";
print "<tr $cb> <td><table>\n";

print "<tr> <td><b>$text{'newdb_db'}</b></td>\n";
print "<td><input name=db size=15></td> </tr>\n";

print "<tr> <td><b>$text{'newdb_table'}</b></td> <td>\n";
print "<input name=table_def type=radio value=1 checked> $text{'newdb_none'}\n";
print "<input name=table_def type=radio value=0>\n";
print "<input name=table size=20></td> </tr>\n";

print "<tr> <td valign=top><b>$text{'newdb_struct'}</b></td>\n";
print "<td><table border>\n";
print "<tr $tb> <td><b>$text{'field_name'}</b></td> ",
      "<td><b>$text{'field_type'}</b></td> ",
      "<td><b>$text{'field_size'}</b></td> </tr>\n";
for($i=0; $i<4; $i++) {
	print "<tr $cb>\n";
	print "<td><input name=field_$i size=20></td>\n";
	print "<td><select name=type_$i>\n";
	print "<option selected>\n";
	foreach $t (@type_list) {
		print "<option>$t\n";
		}
	print "</select></td>\n";
	print "<td><input name=size_$i size=10></td>\n";
	print "</tr>\n";
	}
print "</table></td> </tr>\n";

print "<tr> <td colspan=2 align=right><input type=submit ",
      "value='$text{'create'}'></td> </tr>\n";

print "</table></td></tr></table></form>\n";

print "<hr>\n";
&footer("", $text{'index_return'});

