Location: PHPKode > projects > Matt's March Madness > trunk/submit.php
<?php
include("header.php");

$email = "SELECT email FROM `meta` WHERE `id`=1";

$email = mysql_query($email,$db);
if(!($email = @mysql_fetch_array($email))) {//if fetching the array fails, prompt configuration
	echo "Please <a href=\"admin/install.htm\">configure the site.</a>\n";
	exit();
}
$teams = "SELECT * FROM `master` WHERE `id`=1"; //select teams
$teams = mysql_query($teams,$db);
if(!($teams = @mysql_fetch_array($teams))) {//if fetching the array fails, prompt configuration
	echo "The bracket has not yet been released.\n";
	exit();
}

$teamNames = "SELECT * FROM `master` WHERE `id`=1"; //select teams
$teamNames = mysql_query($teamNames,$db);
if(!($teamNames = @mysql_fetch_array($teamNames))) {//if fetching the array fails, prompt configuration
	echo "The bracket has not yet been released.\n";
	exit();
}

$seeds = "SELECT * FROM `master` WHERE `type`='seeds'"; //select seeds
$seeds = mysql_query($seeds,$db);
if(!($seeds = @mysql_fetch_array($seeds))) {//if fetching the array fails, prompt configuration
	echo "The bracket has not yet been released.\n";
	exit();
}


for( $i=1; $i <= 64; $i++)
{
	$teamNames[$i] = $seeds[$i].". ".$teamNames[$i];
}

$closed = "SELECT `closed` FROM `meta` WHERE `id`=1";
$closed = mysql_query($closed,$db);
$closed = mysql_fetch_array($closed);
if($closed['closed'] != 0) {//if the master bracket has been populated
	echo '<div id="main"><div class="left_side">The competition has begun.  Bracket submission is closed.</div></div><div id="footer">
</div>';
	exit();
}

?>
	<script type="text/javascript">

function validateFields( alertText )
{
	for( var i=1; i<64; i++ )
	{
		var field = document.getElementsByName('game'+i)[0];
		if( field.value == "" )
		{
			alert( "You must pick a winner for this game." );
			field.focus();
			return false;
		}
	}
	
	var moreFields = new Array('bracketname','name','e-mail','tiebreaker');
	
	for( var i=0; i < moreFields.length; i++ )
	{
		var field = document.getElementsByName( moreFields[i] )[0];
		if( field.value == "" )
		{
			alert( "You must fill out this field");
			field.focus();
			return false;
		}
	}
	
	if( alertText != "" )
	{
		return window.confirm(alertText);
	}
	else
	{
		return true;
	}
}
	

	</script>
	
	<div id="main">
		<div class="full">
			<h2>The Bracket</h2>
			<h3>&nbsp;</h3>
			<form method="post" name="bracket" class="bracket" id="bracket" action="bracket.php">
				<?php
				if(isset($_SESSION['errors'])) {
				?>
                <div class="errors"><p><em>Errors:</em></p><?=$_SESSION['errors']?></div>
                <?php 
                }
				unset($_SESSION['errors']);
				?>
				<p class="highlight"><em><strong>Please note:</strong></em> 
				A game is not selected unless it is HIGHLIGHTED. If you leave a game blank, it is an automatic incorrect. If you believe you have made a mistake, <a href="contact.php">contact</a> us.</p>
<p>
If you want a hard copy of your bracket before the tournament begins, please PRINT your bracket before submitting it.</p>
				<table width="700" border="1">
					<tr>
						<td colspan="5"><h1><?php echo $meta['region1']?></h1></td>
					</tr>
					<tr>
						<td>1. <?=$teams['1']?></td>
						<td rowspan="2"><select name="game1" size="2" class="forms" id="game1" onchange="update('game1','game33',0);">
								<option value="<?=$teams[1]?>"><?=$teamNames['1']?></option>
								<option value="<?=$teams[2]?>"><?=$teamNames['2']?></option>
							</select></td>
						<td rowspan="4"><select name="game33" size="2" class="forms" id="game33" onchange="update('game33','game49',0);">
						</select></td>
						<td rowspan="8"><select name="game49" size="2" class="forms" id="game49" onchange="update('game49','game57',0);">
						</select></td>
						<td rowspan="16"><select name="game57" size="2" class="forms" id="game57" onchange="update('game57','game61',0);">
																		</select></td>
					</tr>
					<tr>
						<td>16. <?=$teams['2']?></td>
					</tr>
					<tr>
						<td>8. <?=$teams['3']?></td>
						<td rowspan="2"><select name="game2" size="2" class="forms" id="game2" onchange="update('game2','game33',1);">
								<option value="<?=$teams[3]?>" ><?=$teamNames['3']?></option>
								<option value="<?=$teams[4]?>" ><?=$teamNames['4']?></option>
							</select></td>
					</tr>
					<tr>
						<td>9. <?=$teams['4']?></td>
					</tr>
					<tr>
						<td>5. <?=$teams['5']?></td>
						<td rowspan="2"><select name="game3" size="2" class="forms" id="game3" onchange="update('game3','game34',0);">
								<option value="<?=$teams[5]?>" ><?=$teamNames['5']?></option>
								<option value="<?=$teams[6]?>" ><?=$teamNames['6']?></option>
							</select></td>
						<td rowspan="4"><select name="game34" size="2" class="forms" id="game34" onchange="update('game34','game49',1);">
							</select></td>
					</tr>
					<tr>
						<td>12. <?=$teams['6']?></td>
					</tr>
					<tr>
						<td>4. <?=$teams['7']?></td>
						<td rowspan="2"><select name="game4" size="2" class="forms" id="game4" onchange="update('game4','game34',1);">
								<option value="<?=$teams[7]?>" ><?=$teamNames['7']?></option>
								<option value="<?=$teams[8]?>" ><?=$teamNames['8']?></option>
							</select></td>
					</tr>
					<tr>
						<td>13. <?=$teams['8']?></td>
					</tr>
					<tr>
						<td>6. <?=$teams['9']?></td>
						<td rowspan="2"><select name="game5" size="2" class="forms" id="game5" onchange="update('game5','game35',0);">
								<option value="<?=$teams[9]?>" ><?=$teamNames['9']?></option>
								<option value="<?=$teams[10]?>" ><?=$teamNames['10']?></option>
							</select></td>
						<td rowspan="4"><select name="game35" size="2" class="forms" id="game35" onchange="update('game35','game50',0);">
							</select></td>
						<td rowspan="8"><select name="game50" size="2" class="forms" id="game50" onchange="update('game50','game57',1);">
							</select></td>
					</tr>
					<tr>
						<td>11. <?=$teams['10']?></td>
					</tr>
					<tr>
						<td>3. <?=$teams['11']?></td>
						<td rowspan="2"><select name="game6" size="2" class="forms" id="game6" onchange="update('game6','game35',1);">
								<option value="<?=$teams[11]?>" ><?=$teamNames['11']?></option>
								<option value="<?=$teams[12]?>" ><?=$teamNames['12']?></option>
							</select></td>
					</tr>
					<tr>
						<td>14. <?=$teams['12']?></td>
					</tr>
					<tr>
						<td>7. <?=$teams['13']?></td>
						<td rowspan="2"><select name="game7" size="2" class="forms" id="game7" onchange="update('game7','game36',0);">
								<option value="<?=$teams[13]?>" ><?=$teamNames['13']?></option>
								<option value="<?=$teams[14]?>" ><?=$teamNames['14']?></option>
							</select></td>
						<td rowspan="4"><select name="game36" size="2" class="forms" id="game36" onchange="update('game36','game50',1);">
							</select></td>
					</tr>
					<tr>
						<td>10. <?=$teams['14']?></td>
					</tr>
					<tr>
						<td>2. <?=$teams['15']?></td>
						<td rowspan="2"><select name="game8" size="2" class="forms" id="game8" onchange="update('game8','game36',1);">
								<option value="<?=$teams[15]?>" ><?=$teamNames['15']?></option>
								<option value="<?=$teams[16]?>" ><?=$teamNames['16']?></option>
							</select></td>
					</tr>
					<tr>
						<td>15. <?=$teams['16']?></td>
					</tr>
				</table>
				<table width="700" border="1">
					<tr>
						<td colspan="5"><h1><?php echo $meta['region2']?></h1></td>
					</tr>
					<tr>
						<td>1. <?=$teams['17']?></td>
						<td rowspan="2"><select name="game9" class="forms" size="2" id="game9" onchange="update('game9','game37',0);">
								<option value="<?=$teams[17]?>" ><?=$teamNames['17']?></option>
								<option value="<?=$teams[18]?>" ><?=$teamNames['18']?></option>
							</select></td>
						<td rowspan="4"><select name="game37" class="forms" size="2" id="game37" onchange="update('game37','game51',0);">
						</select></td>
						<td rowspan="8"><select name="game51" class="forms" size="2" id="game51" onchange="update('game51','game58',0);">
						</select></td>
						<td rowspan="16"><select name="game58" class="forms" size="2" id="game58" onchange="update('game58','game61',1);">
						</select></td>
					</tr>
					<tr>
						<td>16. <?=$teams['18']?></td>
					</tr>
					<tr>
						<td>8. <?=$teams['19']?></td>
						<td rowspan="2"><select name="game10" class="forms" size="2" id="game10" onchange="update('game10','game37',1);">
								<option value="<?=$teams[19]?>" ><?=$teamNames['19']?></option>
								<option value="<?=$teams[20]?>" ><?=$teamNames['20']?></option>
							</select></td>
					</tr>
					<tr>
						<td>9. <?=$teams['20']?></td>
					</tr>
					<tr>
						<td>5. <?=$teams['21']?></td>
						<td rowspan="2"><select name="game11" class="forms" size="2" id="game11" onchange="update('game11','game38',0);">
							<option value="<?=$teams[21]?>" ><?=$teamNames['21']?></option>
							<option value="<?=$teams[22]?>" ><?=$teamNames['22']?></option>
							</select></td>
						<td rowspan="4"><select name="game38" class="forms" size="2" id="game38" onchange="update('game38','game51',1);">
							</select></td>
					</tr>
					<tr>
						<td>12. <?=$teams['22']?></td>
					</tr>
					<tr>
						<td>4. <?=$teams['23']?></td>
						<td rowspan="2"><select name="game12" class="forms" size="2" id="game12" onchange="update('game12','game38',1);">
							<option value="<?=$teams[23]?>" ><?=$teamNames['23']?></option>
							<option value="<?=$teams[24]?>" ><?=$teamNames['24']?></option>
							</select></td>
					</tr>
					<tr>
						<td>13. <?=$teams['24']?></td>
					</tr>
					<tr>
						<td>6. <?=$teams['25']?></td>
						<td rowspan="2"><select name="game13" class="forms"  size="2"id="game13" onchange="update('game13','game39',0);">
								<option value="<?=$teams[25]?>" ><?=$teamNames['25']?></option>
								<option value="<?=$teams[26]?>" ><?=$teamNames['26']?></option>
							</select></td>
						<td rowspan="4"><select name="game39" class="forms"  size="2"id="game39" onchange="update('game39','game52',0);">
							</select></td>
						<td rowspan="8"><select name="game52" class="forms"  size="2" id="game52" onchange="update('game52','game58',1);">
							</select></td>
					</tr>
					<tr>
						<td>11. <?=$teams['26']?></td>
					</tr>
					<tr>
						<td>3. <?=$teams['27']?></td>
						<td rowspan="2"><select name="game14" size="2" class="forms" id="game14" onchange="update('game14','game39',1);">
								<option value="<?=$teams[27]?>" ><?=$teamNames['27']?></option>
								<option value="<?=$teams[28]?>" ><?=$teamNames['28']?></option>
							</select></td>
					</tr>
					<tr>
						<td>14. <?=$teams['28']?></td>
					</tr>
					<tr>
						<td>7. <?=$teams['29']?></td>
						<td rowspan="2"><select name="game15" class="forms" size="2" id="game15" onchange="update('game15','game40',0);">
								<option value="<?=$teams[29]?>" ><?=$teamNames['29']?></option>
								<option value="<?=$teams[30]?>" ><?=$teamNames['30']?></option>
							</select></td>
						<td rowspan="4"><select name="game40" class="forms" size="2" id="game40" onchange="update('game40','game52',1);">
							</select></td>
					</tr>
					<tr>
						<td>10. <?=$teams['30']?></td>
					</tr>
					<tr>
						<td>2. <?=$teams['31']?></td>
						<td rowspan="2"><select name="game16" class="forms" size="2" id="game16" onchange="update('game16','game40',1);">
								<option value="<?=$teams[31]?>" ><?=$teamNames['31']?></option>
								<option value="<?=$teams[32]?>" ><?=$teamNames['32']?></option>
							</select></td>
					</tr>
					<tr>
						<td>15. <?=$teams['32']?></td>
					</tr>
				</table>
				<table width="700" border="1">
					<tr>
						<td colspan="5"><h1><?php echo $meta['region3']?></h1></td>
					</tr>
					<tr>
						<td>1. <?=$teams['33']?></td>
						<td rowspan="2"><select name="game17" class="forms" size="2" id="game17" onchange="update('game17','game41',0);">
								<option value="<?=$teams[33]?>" ><?=$teamNames['33']?></option>
								<option value="<?=$teams[34]?>" ><?=$teamNames['34']?></option>
							</select></td>
						<td rowspan="4"><select name="game41" class="forms" size="2" id="game41" onchange="update('game41','game53',0);">
							</select></td>
						<td rowspan="8"><select name="game53" class="forms" size="2" id="game53" onchange="update('game53','game59',0);">
							</select></td>
						<td rowspan="16"><select name="game59" class="forms" size="2" id="game59" onchange="update('game59','game62',0);">
							</select></td>
					</tr>
					<tr>
						<td>16. <?=$teams['34']?></td>
					</tr>
					<tr>
						<td>8. <?=$teams['35']?></td>
						<td rowspan="2"><select name="game18" size="2" class="forms" id="game18" onchange="update('game18','game41',1);">
								<option value="<?=$teams[35]?>" ><?=$teamNames['35']?></option>
								<option value="<?=$teams[36]?>" ><?=$teamNames['36']?></option>
							</select></td>
					</tr>
					<tr>
						<td>9. <?=$teams['36']?></td>
					</tr>
					<tr>
						<td>5. <?=$teams['37']?></td>
						<td rowspan="2"><select name="game19" size="2" class="forms" id="game19" onchange="update('game19','game42',0);">
							<option value="<?=$teams[37]?>" ><?=$teamNames['37']?></option>
							<option value="<?=$teams[38]?>" ><?=$teamNames['38']?></option>
												</select></td>
						<td rowspan="4"><select name="game42" size="2" class="forms" id="game42" onchange="update('game42','game53',1);">
							</select></td>
					</tr>
					<tr>
						<td>12. <?=$teams['38']?></td>
					</tr>
					<tr>
						<td>4. <?=$teams['39']?></td>
						<td rowspan="2"><select name="game20" size="2" class="forms" id="game20" onchange="update('game20','game42',1);">
								<option value="<?=$teams[39]?>" ><?=$teamNames['39']?></option>
								<option value="<?=$teams[40]?>" ><?=$teamNames['40']?></option>
							</select></td>
					</tr>
					<tr>
						<td>13. <?=$teams['40']?></td>
					</tr>
					<tr>
						<td>6. <?=$teams['41']?></td>
						<td rowspan="2"><select name="game21" size="2" class="forms" id="game21" onchange="update('game21','game43',0);">
							<option value="<?=$teams[41]?>" ><?=$teamNames['41']?></option>
							<option value="<?=$teams[42]?>" ><?=$teamNames['42']?></option>
							</select></td>
						<td rowspan="4"><select name="game43" class="forms" size="2" id="game43" onchange="update('game43','game54',0);">
							</select></td>
						<td rowspan="8"><select name="game54" class="forms" size="2" id="game54" onchange="update('game54','game59',1);">
							</select></td>
					</tr>
					<tr>
						<td>11. <?=$teams['42']?></td>
					</tr>
					<tr>
						<td>3. <?=$teams['43']?></td>
						<td rowspan="2"><select name="game22" class="forms" size="2" id="game22" onchange="update('game22','game43',1);">
							<option value="<?=$teams[43]?>" ><?=$teamNames['43']?></option>
							<option value="<?=$teams[44]?>" ><?=$teamNames['44']?></option>
							</select></td>
					</tr>
					<tr>
						<td>14. <?=$teams['44']?></td>
					</tr>
					<tr>
						<td>7. <?=$teams['45']?></td>
						<td rowspan="2"><select name="game23" class="forms" size="2" id="game23" onchange="update('game23','game44',0);">
							<option value="<?=$teams[45]?>" ><?=$teamNames['45']?></option>
							<option value="<?=$teams[46]?>" ><?=$teamNames['46']?></option>
							</select></td>
						<td rowspan="4"><select name="game44" class="forms" size="2" id="game44" onchange="update('game44','game54',1);">
							</select></td>
					</tr>
					<tr>
						<td>10. <?=$teams['46']?></td>
					</tr>
					<tr>
						<td>2. <?=$teams['47']?></td>
						<td rowspan="2"><select name="game24" class="forms" size="2" id="game24" onchange="update('game24','game44',1);">
								<option value="<?=$teams[47]?>" ><?=$teamNames['47']?></option>
								<option value="<?=$teams[48]?>" ><?=$teamNames['48']?></option>
							</select></td>
					</tr>
					<tr>
						<td>15. <?=$teams['48']?></td>
					</tr>
				</table>
				<table width="700" border="1">
					<tr>
						<td colspan="5"><h1><?php echo $meta['region4']?></h1></td>
					</tr>
					<tr>
						<td>1. <?=$teams['49']?></td>
						<td rowspan="2"><select name="game25" class="forms" size="2" id="game25" onchange="update('game25','game45',0);">
							<option value="<?=$teams[49]?>" ><?=$teamNames['49']?></option>
							<option value="<?=$teams[50]?>" ><?=$teamNames['50']?></option>
						</select></td>
						<td rowspan="4"><select name="game45" class="forms" size="2" id="game45" onchange="update('game45','game55',0);">
						</select></td>
						<td rowspan="8"><select name="game55" class="forms" size="2" id="game55" onchange="update('game55','game60',0);">
						</select></td>
						<td rowspan="16"><select name="game60" class="forms" size="2" id="game60" onchange="update('game60','game62',1);">
						</select></td>
					</tr>
					<tr>
						<td>16. <?=$teams['50']?></td>
					</tr>
					<tr>
						<td>8. <?=$teams['51']?></td>
						<td rowspan="2"><select name="game26" class="forms" size="2" id="game26" onchange="update('game26','game45',1);">
								<option value="<?=$teams[51]?>" ><?=$teamNames['51']?></option>
								<option value="<?=$teams[52]?>" ><?=$teamNames['52']?></option>
							</select></td>
					</tr>
					<tr>
						<td>9. <?=$teams['52']?></td>
					</tr>
					<tr>
						<td>5. <?=$teams['53']?></td>
						<td rowspan="2"><select name="game27" class="forms" size="2" id="game27" onchange="update('game27','game46',0);">
							<option value="<?=$teams[53]?>" ><?=$teamNames['53']?></option>
							<option value="<?=$teams[54]?>" ><?=$teamNames['54']?></option>
							</select></td>
						<td rowspan="4"><select name="game46" class="forms" size="2" id="game46" onchange="update('game46','game55',1);">
							</select></td>
					</tr>
					<tr>
						<td>12. <?=$teams['54']?></td>
					</tr>
					<tr>
						<td>4. <?=$teams['55']?></td>
						<td rowspan="2"><select name="game28" class="forms" size="2" id="game28" onchange="update('game28','game46',1);">
								<option value="<?=$teams[55]?>" ><?=$teamNames['55']?></option>
								<option value="<?=$teams[56]?>" ><?=$teamNames['56']?></option>
							</select></td>
					</tr>
					<tr>
						<td>13. <?=$teams['56']?></td>
					</tr>
					<tr>
						<td>6. <?=$teams['57']?></td>
						<td rowspan="2"><select name="game29" class="forms" size="2" id="game29" onchange="update('game29','game47',0);">
								<option value="<?=$teams[57]?>" ><?=$teamNames['57']?></option>
								<option value="<?=$teams[58]?>" ><?=$teamNames['58']?></option>
							</select></td>
						<td rowspan="4"><select name="game47" class="forms" size="2" id="game47" onchange="update('game47','game56',0);">
							</select></td>
						<td rowspan="8"><select name="game56" class="forms" size="2" id="game56" onchange="update('game56','game60',1);">
							</select></td>
					</tr>
					<tr>
						<td>11. <?=$teams['58']?></td>
					</tr>
					<tr>
						<td>3. <?=$teams['59']?></td>
						<td rowspan="2"><select name="game30" class="forms" size="2" id="game30" onchange="update('game30','game47',1);">
								<option value="<?=$teams[59]?>" ><?=$teamNames['59']?></option>
								<option value="<?=$teams[60]?>" ><?=$teamNames['60']?></option>
							</select></td>
					</tr>
					<tr>
						<td>14. <?=$teams['60']?></td>
					</tr>
					<tr>
						<td>7. <?=$teams['61']?></td>
						<td rowspan="2"><select name="game31" class="forms" size="2" id="game31" onchange="update('game31','game48',0);">
								<option value="<?=$teams[61]?>" ><?=$teamNames['61']?></option>
								<option value="<?=$teams[62]?>" ><?=$teamNames['62']?></option>
							</select></td>
						<td rowspan="4"><select name="game48" class="forms" size="2" id="game48" onchange="update('game48','game56',1);">
							</select></td>
					</tr>
					<tr>
						<td>10. <?=$teams['62']?></td>
					</tr>
					<tr>
						<td>2. <?=$teams['63']?></td>
						<td rowspan="2"><select name="game32" class="forms" size="2" id="game32" onchange="update('game32','game48',1);">
								<option value="<?=$teams[63]?>" ><?=$teamNames['63']?></option>
								<option value="<?=$teams[64]?>" ><?=$teamNames['64']?></option>
							</select></td>
					</tr>
					<tr>
						<td>15. <?=$teams['64']?></td>
					</tr>
				</table>
				<p>&nbsp;</p>
				<table width="700" border="1">
					<tr>
						<td colspan="3"><h1 align="center">FINAL FOUR</h1></td>
					</tr>
					<tr>
						<td><?php echo $meta['region1']?> Champion </td>
						<td rowspan="2"><select name="game61" size="2" class="forms" id="game61" onchange="update('game61','game63',0);">
						</select></td>
						<td rowspan="4"><select name="game63" size="2" class="forms" id="game63">
						</select></td>
					</tr>
					<tr>
						<td><?php echo $meta['region2']?> Champion </td>
					</tr>
					<tr>
						<td><?php echo $meta['region3']?> Champion </td>
						<td rowspan="2"><select name="game62" size="2" class="forms" id="game62" onchange="update('game62','game63',1);">
						</select></td>
					</tr>
					<tr>
						<td><?php echo $meta['region4']?> Champion </td>
					</tr>
				</table>
									<br />
				<p align="center"><label for="name">Bracket Name:</label><input name="bracketname" type="text" id="bracketname" /></p>
				<p align="center"><label for="e-mail">Your Name:</label><input name="name" type="text" id="name" /></p>
				<p align="center"><label for="e-mail">E-Mail Address:</label><input name="e-mail" type="text" id="e-mail" /></p>
				<!--<p align="center"><label for="password">Submission Code:</label><input name="password" type="text" id="password" /></p>-->
				<p align="center">Tiebreaker (total points scored in championship)
					<input name="tiebreaker" type="text" id="tiebreaker" size="10" maxlength="3" />
					<br />
					<br />
					<input type="submit" name="submit" value="Submit" onclick="return validateFields('All fields appear to be filled. Are you sure you want to submit this bracket?')" />
					<input type="reset" name="reset"  value="Reset (BE CAREFUL!)" onclick="return resetBracket();" />
					<input type="submit" name="print" value="Print Your Bracket!" onclick="if(validateFields('')){ document.bracket.target='_blank'; } else { return false;}" />
				</p>
			</form>
		</div>
	</div>
	<div id="footer"> </div>
</div>
</body>
</html>
Return current item: Matt's March Madness