addteam
<?php
include 'localsettings.php';
?>
<html>
<head>
<title>MW Move Banker</title>
</head>
<body>
<H1>MinuteWar Move Banker</H1>
<?php
// first check if team name is already in the database
$sql = "SELECT TeamName FROM MWMoves WHERE TeamName='".$_POST["T"]."'";
$result = mysql_query($sql, $db);
//echo "Found ".mysql_num_rows($result)." teams\n";
if (($result) && (mysql_num_rows($result)!=0)) {
echo "The team name, ".$_POST["T"].", already exists<p>";
echo "please use the back button and choose a different name<p>";
exit(1);
}
// check that teamname and password are not empty
if ((!isset($_POST["T"])) || (strlen($_POST["T"]) == 0)) {
echo "The team name cannot be blank.<br>";
echo "please use the back button and choose a different name<p>";
exit(1);
}
if ((!isset($_POST["G"])) || (strlen($_POST["G"]) == 0)) {
echo "You must select a game.<br>";
echo "please use the back button and choose a game<p>";
exit(1);
}
if ((!isset($_POST["PW"])) || (strlen($_POST["PW"]) == 0)) {
echo "The password cannot be blank.<br>";
echo "please use the back button and choose a different password<p>";
exit(1);
}
// insert new record in the database
$sql = "INSERT INTO `MWMoves` ( `TeamName` , `Game` , `Password`) VALUES ('".$_POST["T"]."', '".$_POST["G"]."', '".$_POST["PW"]."')";
$result = mysql_query($sql, $db);
if ((!$result) || (mysql_affected_rows()==0)) {
echo "Failed to store team information in db<p>";
echo "query was $sql<p>";
} else {
// success, give the use some info
?>
<h2></h2>Your team has been created.</h2>
Team Name:<b> <?php echo $_POST["T"]?></b><p>
Password:<b> <?php echo $_POST["PW"]?></b><p>
Game:<b> <?php echo $_POST["G"]?></b><p>
You may wish to print this page for your records.<br>
You should send this information to other players on your team. You all share the password.
<p> <p>
<p>
Welcome to MinuteWar Move Banking
<?php
}
?>
<H2><a href="index.php">HOME</a></H2>
</body>
</html>