<?php
session_start();
include("include/header.php");
if($_POST['action']=='SUBMIT')
{
	
	$email = trim($_POST['emailid']);

	$lginErr="";

	if(trim($email)== "") 
		$lginErr = "&nbsp;&nbsp;Email is required.<br/>";

	if(trim($lginErr)=="")
	{
		$strSql =@mysql_query("select * from tr_parent where email='".$_POST['emailid']."'");
		$rs = @mysql_fetch_array($strSql);

		$pasw=$rs['password']; 
		$mname=$rs['Name'];

		
		//mail code start

		//$sendTo = "sales@lunchpails.ca";
		$sendTo = $email; 
		$subject = "Sub : Password Request";

		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$headers .= "From:no-replay<no-replay@lunchpails.ca> \r\n";


			$message = "Dear ".$mname." ,\r\n<br> The Following are the Account Details of Lunchpails Parent Login. <br /><br />\r\n";
			$message .= "  User Name".$email."<br /><br />\r\n";
			$message .= " Password : ".$pasw."<br /><br />\r\n";
			
			$message .="Thanks";

		mail($sendTo, $subject, $message, $headers);

		//$ErrorMessage = "Thank you for your interest in our business. Someone will be in contact with you to provide you with more information";

		$lginErr="You will receive an email shortly with your Password";


		
	}
}
?>
<tr>
	<td width="900" class="fs15 blue">
		<table border="0" cellpadding="1" cellspacing="1" width="100%" align="center" height='150px'>

		<tr><td colspan="2" height="20px">&nbsp;</td></tr>
		<tr><td colspan="2"><hr /></td></tr>

		<?php	if(strtoupper(substr(trim($lginErr),0,16)) == "YOU WILL RECEIVE")
		{
				echo "<tr valign='top' align='center'><td colspan='4'>".$lginErr."</td></tr>";
		?>
				<meta http-equiv="Refresh" content="5;url=parentLogin.php"><br/><br/><br/><br/><br/>
		<?php
		}
		else
		{
			?>
			 <form action="forget_pasw.php" method="POST" name="frm">
				<tr>
					<td align="center" colspan="2" height="60px">Forgot Your Password?</td>
				</tr> 
				<tr>
					<td align="center" colspan="2" height="60px">Please enter the email address you registered with and we will email your password to you.</td>
				</tr>

				<tr>
					<td width="300" align="right"><b>Email ID:</b>&nbsp;&nbsp;</td><td width="600"><input type="text" name="emailid" size="35" maxlength="100" value="<?=$login?>" /></td>
				</tr>
				 <tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td width="30%" class="errmsg" colspan='2'align='center' ><?=$lginErr?></td>
				</tr>

				<tr>
					<td colspan='2' align='center'><input type="submit" name="action" value="SUBMIT" /></td></td>
				</tr>
				
				<tr>
					<td align="center" colspan="2" height="20px">&nbsp;</td>
				</tr>
			</form>	
			<?php
		}
				?>
							<tr><td colspan="2"><hr /><br /><br /></td></tr>

		</table>
	</td>
</tr>
<?php
include("include/footer.php");
?>