<? require_once "application_top.php"; ?>
<?
if(isset($_REQUEST['emailid'])&&($_REQUEST['emailid'])){

$adminemailid = "info@biharbloodbank.com";

	$fnames = $_REQUEST['fname'];
	$emailids = $_REQUEST['emailid'];
	
	$msg = "";
	$cnt = 0;
	foreach($emailids as $emailid){
		if($emailid){
		$to = $emailid;
		$subject = "visit biharbloodbank.com";
		$message = "Your friend ".$_REQUEST['yourfname']. " (".$_REQUEST['youremailid'].") thought you could be interested to post your details on http://www.biharbloodbank.com/ <br/>
					<table cellpaddig=5>
					<tr>
						<td><b>Message</b></td><td>: ".addslashes($_POST['description'])."</td>
					</tr>
					
					</table>";
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";		
		$headers .= "From: ".$adminemailid." <".$adminemailid.">\r\n";
		$headers .= 'To: '.$to.' <'.$to.'>'."\r\n";
		//$headers .= 'Bcc: <hemant@hemantjadhav.com>\r\n';
		//exit;

		
		$mailit = mail($to,$subject,$message,$headers);
			if ( $mailit ) {
			$msg .= "<div class=msg>Mail sent successfully to ".$fnames[$cnt]."</div>";
			}else{
			$msg .= "<div class=msg>Mail could not be sent this time to ".$fnames[$cnt]."! try again.</div>";
			}
		}
		$cnt++;
	}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Bihar Blood Bank</title>

<? include ("include/header.php"); ?>
	<table id="containerTable">
	<tr>
		<td width="220">
		<? require "left.php";?>
		</td>
		
		<td width="500px;">
		<?=$msg;?>
		<h1>Invite your friends</h1>
		
		<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" name="invitefrm" id="invitefrm">
		<table>
		<tr>
			<td>
				Your Name:<br/>
				<input type="text" name="yourfname" class="required"/>
			</td>
			<td>Your Emailid:<br/><input type="text" name="youremailid" class="required email"/></td>
		</tr>
		<tr>
			<td>Your friends Name:<br/><input type="text" name="fname[]" class="required"/></td>
			<td>Your friends Emailid:<br/><input type="text" name="emailid[]"  class="required email"/></td>
		</tr>
		<tr>
			<td><input type="text" name="fname[]" class="required"/></td>
			<td><input type="text" name="emailid[]"  class="required email"/></td>
		</tr>
		<tr>
			<td><input type="text" name="fname[]" class="required"/></td>
			<td><input type="text" name="emailid[]"  class="required email"/></td>
		</tr>
		<tr>
			<td><input type="text" name="fname[]" class="required"/></td>
			<td><input type="text" name="emailid[]"  class="required email"/></td>
		</tr>
		<tr>
			<td><input type="text" name="fname[]" class="required"/></td>
			<td><input type="text" name="emailid[]"  class="required email"/></td>
		</tr>
		
		<tr>
			<td></td><td><input type="submit" value=" Send Invite " class="button"/></td>
		</tr>
		</table>
		</form>
		
		</td>
		
		<td width="220" align="right">
		<? require "right.php";?>
		</td>
	</tr>
	</table>
	
<? include ("include/footer.php"); ?>