<?
include("common.php");


if ($_POST)
{
	$toscreen="";
	//check for for email in person table
	$SQL="SELECT * FROM execdir WHERE email like '".secure_user_input($_POST['email'])."'" ;
	$results = llnb_query($SQL);
	$row = llnb_fetch_assoc($results);
	
	if (!$row)
	{
		$SQL="SELECT * FROM coordinator WHERE email like '".secure_user_input($_POST['email'])."'" ;
		$results = llnb_query($SQL);
		$row = llnb_fetch_assoc($results);
	}
	
	if (!$row)
	{
		$SQL="SELECT * FROM tutor WHERE email like '".secure_user_input($_POST['email'])."'" ;
		$results = llnb_query($SQL);
		$row = llnb_fetch_assoc($results);
	}
	
	
	if ($row)
	{
		$headers = 'From: LLNB <info@ravenssun.ca>' . "\r\n" .
		    'Reply-To: info@ravenssun.ca' . "\r\n";
    
    		mail($_POST['email'], 'LLNB Password', "Your password is: ".$row['password'], $headers);
    		$toscreen="Password has been sent to you:". $_POST['email'];
    	 }
    	 else
    		 $toscreen="Email address not found in our records.";
}






?>

<!doctype html>
<html class="no-js" lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">

  <!-- Use the .htaccess and remove these lines to avoid edge case issues.
       More info: h5bp.com/i/378 -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>LLNB System</title>
  <meta name="description" content="">

  <!-- Mobile viewport optimized: h5bp.com/viewport -->
  <meta name="viewport" content="width=device-width, maximum-scale=1.0">

  <!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->
  <LINK REL="SHORTCUT ICON" HREF="favicon.ico">

  <link rel="stylesheet" href="css/style.css">
  <link rel="stylesheet" href="css/llnb-style.css">

  <!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->

  <script src="js/libs/modernizr-2.5.3.min.js"></script>
  <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
  <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css">
</head>
<body onLoad="document.forms.fpassword.email.focus()">

<div id="wrap" style=" -moz-border-radius: 20px; -webkit-border-radius: 20px; -khtml-border-radius: 20px; border-radius: 20px;width: 250px;height: auto; position: absolute;left: 50%; top: 40%; margin-left: -125px; margin-top: -112px; padding: 15px;">
  <header  style="padding: 0;">
		<h2>Forgot Password</h2>
  </header>
  <div role="main">
  
	<form method="POST" name="fpassword" action="forgotpassword.php">
    <span id="sprypassword1">
    	<label>Enter Email Address:</label>
    	<?
    	if ($_POST)
    	{
    	 		echo "<label>".$toscreen."</label>";
    	 		echo "<p><a href=\"forgotpassword.php\" class=\"btn btnhidden\">Forgot your password?</a>
    	 		<p>
    	 		<a href=\"index.php\" class=\"btn lfr\">Main Page</a>";
    	 		
    	}
    	else
    	{
		  echo 
			"<input type=\"email\" name=\"email\" id=\"email\" style=\"width: 240px;\">
			<span class=\"passwordRequiredMsg\">A value is required.</span></span>

		   <label>Your password will be sent to your email address. Email address must match the email in the system, if you have changed your email address contact the administration.</label>
		   <p><input type=\"submit\" class=\"btn lfr\" value=\"Send\">
		   <a href=\"index.php\" class=\"btn lfr\">Cancel</a></p>
		   <span class=\"clearfix\"></span>";
	 }
 
 ?>
 </form>    
  
  
  
  </div>
  <footer>

  </footer>
  </div> <!-- end of wrap -->

  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

  <!-- scripts concatenated and minified via build script -->
<script src="js/plugins.js"></script>
<script src="js/script.js"></script>
  <!-- end scripts -->

<script type="text/javascript">
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
  </script>
</body>
</html>