<?php

if($parse == "true"){

	if($usr=="") {
		die (print_page("The username field cannot be left blank."));
	}

	if($pass==""){
		die (print_page("The password field cannot be left blank."));
	}

	// connect to db
	$db = mysql_connect("db1.thinkhost.com", "midwestskibums", "midwestskibums") 
	    	or die (print_page("There was an error connecting to the login server.  Please try again later."));

	mysql_select_db("midwestskibums", $db) 
		or die (print_page("There was an error finding the login database.  Please try again later."));

	$sql = "SELECT * FROM user WHERE login = '$usr' and password = '$pass'";
	$value = mysql_fetch_array(mysql_query($sql)) 
		or die (print_page("The login information you have supplied is incorrect."));

	if($value=""){
		die (print_page("The login information you have supplied is incorrect."));
	}

	if($usr == "officer"){
	setcookie("uname", "officer");
	}

	setcookie("validuser", "true");
	header ("Location: http://www.midwestskibums.com/wmuskiteam/memberinfo.phtml");
}
else{
	print_page($mess);
}


function print_page($loginmessage){
echo "<html>

<head>
<title>Sigma Kappa Iota</title>
</head>

<body link=\"#000000\" vlink=\"#000000\" background=\"http://www.midwestskibums.com/wmuskiteam/back.jpg\">

<table border=\"0\" width=\"968\">
  <tr>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/officers.htm\">Officers</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/info.htm\">Information</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/schedule.htm\">Schedule</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\">Members</font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/results.htm\">Results</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/links.htm\">Links</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/store.htm\">Store</a></font></td>
    <td align=\"center\"><font face=\"Arial Black\" size=\"4\"><a href=\"http://www.midwestskibums.com/wmuskiteam/pics.htm\">Pictures</a></font></td>
  </tr>
</table>

<table border=\"0\" width=\"968\" height=\"88\">
  <tr>
    <td width=\"1322\" colspan=\"3\" bgcolor=\"#BBA301\" height=\"1\"><font face=\"Arial\"><b>
       <marquee scrollamount=\"3\" scrolldelay=\"1\"><script Language=\"Javascript\" src=\"http://www.midwestskibums.com/wmuskiteam/content.js\"></script></marquee>
      </b></font></td>
  </tr>
  <tr>
    <td align=\"center\" valign=\"top\" height=\"15\" rowspan=\"2\"><a href=\"http://www.midwestskibums.com/wmuskiteam/index.html\"><img border=\"0\" src=\"http://www.midwestskibums.com/wmuskiteam/logom.gif\" width=\"228\" height=\"169\"></a></td>
    <td width=\"473\" align=\"center\" valign=\"middle\" height=\"1\"><b><font face=\"Arial\" size=\"4\">MEMBERS</font></b></td>
    <td align=\"center\" valign=\"top\" height=\"15\" rowspan=\"2\"><a href=\"http://www.midwestskibums.com/wmuskiteam/index.html\"><img border=\"0\" src=\"http://www.midwestskibums.com/wmuskiteam/ski.gif\" width=\"228\" height=\"181\"></a></td>
  </tr>
  <tr>
    <td width=\"473\" align=\"center\" valign=\"top\" height=\"54\">&nbsp;
      <p><font face=\"Arial\" size=\"2\">This is a secure section of the
      website.&nbsp; Please login with a username and password below.</font></p>
      <form method=\"POST\" action=\"members.phtml\">
	<input type=\"hidden\" name=\"parse\" value=\"true\">
        <p style=\"word-spacing: 0; margin-top: 0; margin-bottom: 0\"><font face=\"Arial\" size=\"2\"><b>Username:</b>
        </font><input type=\"text\" name=\"usr\" size=\"20\"></p>
        <p style=\"word-spacing: 0; margin-top: 0; margin-bottom: 0\"><font size=\"2\" face=\"Arial\"><b>Password:
        </b></font><input type=\"password\" name=\"pass\" size=\"20\"></p>
        <p style=\"word-spacing: 0; margin-top: 0; margin-bottom: 0\"><input type=\"submit\" value=\"Login\" name=\"B1\"></p>
      </form>
      <p><font face=\"Arial\" size=\"2\" color=\"red\">$loginmessage</font></td>
  </tr>
  <tr>
    <td width=\"1322\" align=\"center\" valign=\"middle\" colspan=\"3\" height=\"65\">
      <p style=\"margin-top: 0; margin-bottom: 0\"><font face=\"Arial\" size=\"1\">Copyright
      WMU Alpine Ski &amp; Snowboard Team 2003.</font></p>
      <p style=\"margin-top: 0; margin-bottom: 0\"><font face=\"Arial\" size=\"1\">Site
      design by: Bill Hartman</font></td>
  </tr>
</table>

</body>

</html>";
}

?>
