<?
//error_reporting(E_ERROR);
?>
<? require_once "application_top.php"; ?>
<?
if(isset($_REQUEST['email']) && ($_REQUEST['email'])){
	
	require_once "include/dbconnect.php";
	
	$fname = $_REQUEST['fname']; 
	$ipassword = $_REQUEST['ipassword']; 
	$ddob = $_REQUEST['ddob'];  
	$mdob = $_REQUEST['mdob'];
	$ydob = $_REQUEST['ydob'];
	$bloodgroup = $_REQUEST['bloodgroup']; 
	$mobile = $_REQUEST['mobile']; 
	$dayphone = $_REQUEST['dayphone']; 
	$evephone = $_REQUEST['evephone']; 

	
	$state = $_REQUEST['stateId2']; 
	$city = $_REQUEST['mycity']; 
	$town = $_REQUEST['town']; 

	$how_often = $_REQUEST['how_often']; 

	$username = $_REQUEST['username']; 
	
	$gender = $_REQUEST['gender']; 
	$weight = $_REQUEST['weight']; 

	$email = $_REQUEST['email']; 

	$dlast = $_REQUEST['dlast']; 
	$mlast = $_REQUEST['mlast']; 
	$ylast = $_REQUEST['ylast']; 

	$chkHideMobile = (isset($_REQUEST['chkHideMobile']))? $_REQUEST['chkHideMobile'] : ""; 
	
	
	$sql = "select uid from users where username = '".$_REQUEST['username']."' limit 0,1";
	$results = mysql_query($sql) or die(mysql_error());
	$numrow = mysql_num_rows($results);
	if($numrow){
		header("location:registration.php?msg=<div class='msg'>Username already exist</div>");
	}else{
		$sql = "insert into users (fname, ddob, mdob, ydob, bloodgroup, mobile, dayphone, evephone, chkSMS, state, city, town, how_often, username, ipassword, gender, weight, email, dlast, mlast, ylast, chkHideMobile, suffered1 ) values ('$fname', '$ddob', '$mdob', '$ydob', '$bloodgroup', '$mobile', '$dayphone', '$evephone', '$chkSMS', '$state', '$city', '$town', '$how_often', '$username', '$ipassword', '$gender', '$weight', '$email', '$dlast', '$mlast', '$ylast', '$chkHideMobile', '$suffered1')";
		$results = mysql_query($sql) or die(mysql_error());
		
		$adminemailid = "info@biharbloodbank.in";
		$to = $email;
		$subject = "biharbloodbank.in Registration";
		$message = "<table cellpaddig=5>
					<tr>
					<td>
					Biharbloodbank.in is not any commercial website for blood sale or purchase, its a web based free medium between donor and needy person.
					<br/><br/>
					Important : All Voluntary Donors are warned of likely misuse of blood donated by them at the hospital with or without the knowledge of the hospital management. We have come to know of such misuse at various towns and cities. Biharbloodbank.com requests all donors to take a little extra care by verifying the genuine need by contacting the patient's relatives and doctors. At some places the hospital staff have taken the blood and sold it to others for a price. As a responsible citizen/donor we request you to keep a watch on such people and hospitals. There is a severe shortage of safe blood and voluntary donors. Donors must inform the Biharbloodbank.com team members/coordinators of such areas in case of any doubt. 
					<br/><br/>
					If you want any perssonal assitance in blood donation then kindlycontact Mr. Mukesh Hissariya - +91-9308393446
					<br/><br/>
					</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</div>";
			}else{
			$msg .= "<div class=msg>Mail could not be sent this time try again.</div>";
			}
		

		$message = 	"Name: " . $fname . "<br/>".
				"DOB: " . $ddob . "-".$mdob."-".$ydob." <br/>".
				"Blood group: " . $bloodgroup . "<br/>".
				"Mobile: " . $mobile . "<br/>".
				"Day Phone: " . $dayphone . "<br/>".
				"Evening Phone: " . $evephone . "<br/>".
				"check SMS: " . $chkSMS . "<br/>".
				"state: " . $state . "<br/>".
				"city: " . $city . "<br/>".
				"town: " . $town . "<br/>".
				"How often: " . $how_often . "<br/>".
				"Gender: " . $gender . "<br/>".
				"weight: " . $weight . "<br/>".
				"email: " . $email . "<br/>".
				"Username: " . $username . "<br/>".
				"Last donated: " . $dlast . "-" . $mlast . "-" . $ylast . "<br/>";
		
		$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: '.$adminemailid.' <'.$adminemailid.'>'."\r\n";
		$mailit = mail($adminemailid,$subject,$message,$headers);
		
		}
		
		header("location:registration.php?msg=<div class=msg>Record submitted successfully</div>".$msg);
	}
?>

<!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" border="0">
	<tr>
		<td width="220">
		<? require "left.php";?>
		</td>
		
		<td width="500px;text-align:center;">
		
		<h1>Registration</h1>
		
		<?=$msg;?>
		
		<div id="form">
		
		<form name="newfrm" id="newfrm" action="<?=$_SERVER['PHP_SELF'];?>" method="post" onsubmit="return validateForm();" style="margin:0px;">

		<fieldset>
			<div align="right"  class="linktxt" >* Mark fields are mandatory</div>	
			<div style="width:255px;float:left;">
				<div style="padding:10px;"><span><font class="boldtxt">Name<font class="formclr">*</font> :</font></span><br>
				<input type="text" name="fname" id="fname" value="" class="required" size="30" maxlength="50">
				</div>
				<div style="padding:10px;padding-top:18px;"><span><font class="boldtxt">Password<font class="formclr">*</font>:</font></span><br>
				<input type="password" name="ipassword" id="ipassword" value="" class="required" minlength="4" size="30"><br>
				<font class="frmcomments">Minimum 4 characters allowed</font></div>
				<div style="padding:10px;padding-top:8px;"><span><font class="boldtxt">Date of Birth<font class="formclr">*</font>:</font><br>
				<font class="frmcomments">(min: 18 yrs  max: 55 yrs)</font><br>
				
				<select style="width:45px;" NAME="ddob" id="ddob" size="1"  class="required">
					<option value="">DD
					<option value="1" >1<option value="2" >2<option value="3" >3<option value="4" >4<option value="5" >5<option value="6" >6<option value="7" >7<option value="8" >8<option value="9" >9<option value="10" >10<option value="11" >11<option value="12" >12<option value="13" >13<option value="14" >14<option value="15" >15<option value="16" >16<option value="17" >17<option value="18" >18<option value="19" >19<option value="20" >20<option value="21" >21<option value="22" >22<option value="23" >23<option value="24" >24<option value="25" >25<option value="26" >26<option value="27" >27<option value="28" >28<option value="29" >29<option value="30" >30<option value="31" >31
				</select>
				
				<select style="width:45px;" NAME="mdob" id="mdob" size="1"  class="required">
					<option value="">MM
					<option value="1" >1<option value="2" >2<option value="3" >3<option value="4" >4<option value="5" >5<option value="6" >6<option value="7" >7<option value="8" >8<option value="9" >9<option value="10" >10<option value="11" >11<option value="12" >12
				</select>
				
				<select style="width:65px;" NAME="ydob" id="ydob" size="1"  class="required">
					<option value="">YYYY
					<option value="1950" >1950<option value="1951" >1951<option value="1952" >1952<option value="1953" >1953<option value="1954" >1954<option value="1955" >1955<option value="1956" >1956<option value="1957" >1957<option value="1958" >1958<option value="1959" >1959<option value="1960" >1960<option value="1961" >1961<option value="1962" >1962<option value="1963" >1963<option value="1964" >1964<option value="1965" >1965<option value="1966" >1966<option value="1967" >1967<option value="1968" >1968<option value="1969" >1969<option value="1970" >1970<option value="1971" >1971<option value="1972" >1972<option value="1973" >1973<option value="1974" >1974<option value="1975" >1975<option value="1976" >1976<option value="1977" >1977<option value="1978" >1978<option value="1979" >1979<option value="1980" >1980<option value="1981" >1981<option value="1982" >1982<option value="1983" >1983<option value="1984" >1984<option value="1985" >1985<option value="1986" >1986<option value="1987" >1987<option value="1988" >1988<option value="1989" >1989<option value="1990" >1990<option value="1991" >1991<option value="1992" >1992<option value="1993" >1993<option value="1994" >1994<option value="1995" >1995<option value="1996" >1996<option value="1997" >1997<option value="1998" >1998<option value="1999" >1999<option value="2000" >2000<option value="2001" >2001<option value="2002" >2002<option value="2003" >2003<option value="2004" >2004<option value="2005" >2005<option value="2006" >2006<option value="2007" >2007<option value="2008" >2008<option value="2009" >2009<option value="2010" >2010<option value="2011" >2011</option>
				</select><br><font class="frmcomments">Date of birth will not be shown to others. It's only for calculating your age.</font>
				
				</div>

				<div style="padding:10px;padding-top:1px;"><span><font class="boldtxt">Blood Group<font class="formclr">*</font> </font></span><br>
				
				<select style="width:100px;" class="required" name="bloodgroup" id="bloodgroup" size="1">
				<option value="">Select
					<option value="O+" > O+
					<option value="O-" > O-
					<option value="B+" > B+
					<option value="B-" > B-	
					<option value="A+" > A+
					<option value="A-" > A-
					<option value="AB+" > AB+
					<option value="AB" > AB-
					<option value="A1+" > A1+
					<option value="A1-" > A1-
					<option value="A2+" > A2+
					<option value="A2-" > A2-
					<option value="A1B+" > A1B+
					<option value="A1B-" > A1B-
					<option value="A2B+" > A2B+
					<option value="A2B-" > A2B-
				</select>
				</div>
			
				<div class="left" style="padding:10px;"><span><font class="boldtxt">Contact Number :</font></span>
					<div class="left" style="padding-bottom:10px;width:60px;">Mobile<font class="formclr">*</font>:</div>
					<div class="left" style="padding-bottom:10px;">
					<input type="text" name="mobile" id="mobile" class="required" value=""></div><br clear="all">
					<div class="left" style="padding-bottom:10px;width:60px;">Residence:</div>
					<div class="left" style="padding-bottom:10px;">
					<input type="text" name="dayphone" id="dayphone" class="textbox" value=""></div><br clear="all">
					<div class="left" style="padding-bottom:10px;width:60px;">Office:</div>
					<div class="left" style="padding-bottom:10px;">
					<input type="text" name="evephone" id="evephone" class="textbox" value=""></div><br clear="all">
					<font class="frmcomments">Note: Please provide at least one contact number. But it is recommended to provide as many contact numbers as possible because it will be easier for the recipients to contact you in times of emergency. Remember a life may be depending on you!</font>
				</div><br clear="all">
				<div style="padding:10px;"><span><font class="boldtxt">SMS Alert :</font></span>
				<INPUT TYPE="checkbox" NAME="chkSMS"  id="chkSMS"  value="1" ><br><font class="frmcomments">You will receive an alert on your mobile when there is a request for your blood type within your city.</font></div>
				<div style="padding:10px;"><span><font class="boldtxt">State<font class="formclr">*</font>:</font></span><br>
				<div id="state">
					<? 
					$StateInputIdName = "stateId2";
					include "include/states.php"; 
					?>
				</div>
				</div>
				<div style="padding:10px;"><span><font class="boldtxt">City<font class="formclr">*</font>:</font></span><br>
				<div id="afdd">
					<? 
					$loaderDivName = "cityDiv2";
					include "include/cities.php";?>
				</div>
				</div>
				<div style="padding:10px;"><span><font class="boldtxt">Area<font class="formclr">*</font>:</font><br>		
				<div id="area">
				<select style="width:200px;" class="required" id="town" NAME="town" size="1">		
					<option value="">Select Area</option>
					<option value="all">All</option>
				</select></div>
				</div>
				<div style="padding:10px;"><span><font class="boldtxt">How often have you donated blood in the past?</font></span><br>
					<select style="width:100px;" class="smalltxt textbox" name="how_often" id="how_often" size="1">
						<option value="yet to donate" >Yet to donate</option>
						<option value="regular donor" >Regular donor</option>
						<option value="on need basis" >On need basis</option>
					</select>


 <label for="code">Write code below > <span id="txtCaptchaDiv" style="color:#F00"></span><!-- this is where the script will place the generated code --> 
      <input type="hidden" id="txtCaptcha" /></label><!-- this is where the script will place a copy of the code for validation: this is a hidden field -->
      <input type="text" name="txtInput" id="txtInput" size="30" />




				</div>
				
			</div>
			<div class="left" style="border-left:1px dotted #000000;width:235px;float:left;">	
				<div style="padding:10px;"><span><font class="boldtxt">Username<font class="formclr">*</font>:</font></span><br><input type="text" name="username" id="username" value="" class="required" size="30" minlength="6" maxlength="50"><br><font class="frmcomments">(min 6 characters) <a href="javascript:void(0);" title="Check username availability" class="checkavail">Check Availability?</a><br/><span id="checkavailDiv"></span></font></div>
				<div style="padding:10px;padding-top:0px;"><span><font class="boldtxt">Confirm Password<font class="formclr">*</font>:</font></span><br><input type="password" name="reipassword" id="reipassword" class="equalTo ipassword" size="30"><br><font class="frmcomments">Please re-enter your password</font></div>
				<div style="padding:10px;padding-top:6px;"><span><font class="boldtxt">Gender<font class="formclr">*</font> :</font><br></span>Female <input type="radio" name="gender" value="F" id="gender" class="required"><br>Male <input type="radio" name="gender" id="gender" value="M" ></div>
				<div style="padding:10px;padding-top:30px;"><span><font class="boldtxt">Weight<font class="formclr">*</font>:</font><br></span><input type="text" name="weight" id="weight" size=5 maxlength=3 value="" class="required"> Kgs<br><font class="frmcomments">(should be above 50 kg)</font></div>
				
				<div style="padding:0px 10px 10px 10px;"><span><font class="boldtxt">E-mail<font class="formclr">*</font>:</font><br></span><INPUT TYPE="text" size="25" NAME="email" id="email" value="" class="required email"><br><font class="frmcomments">We recommend you enter the e-mail ID, which will help us get in touch with you in case you are not reachable by phone. It will be greater help if you could provide us your personal e-mail ID besides your corporate e-mail ID. You can always be reached to save a life!</font></div>
				<!-- <div style="padding:10px;"><span><font class="boldtxt">Mail Alert :</font></span><INPUT TYPE="checkbox" NAME="chkMail"    value="1" ></div> -->
				
				
				<div style="padding:10px;"><span><font class="boldtxt">Date of last blood donation :</font></span><br>
				
				<select style="width:45px;" class="smalltxt textbox" NAME="dlast" id="dlast" size="1">
					<option value="">DD
					<option value="1" >1<option value="2" >2<option value="3" >3<option value="4" >4<option value="5" >5<option value="6" >6<option value="7" >7<option value="8" >8<option value="9" >9<option value="10" >10<option value="11" >11<option value="12" >12<option value="13" >13<option value="14" >14<option value="15" >15<option value="16" >16<option value="17" >17<option value="18" >18<option value="19" >19<option value="20" >20<option value="21" >21<option value="22" >22<option value="23" >23<option value="24" >24<option value="25" >25<option value="26" >26<option value="27" >27<option value="28" >28<option value="29" >29<option value="30" >30<option value="31" >31			</select>
				<select style="width:45px;" class="smalltxt textbox" NAME="mlast" id="mlast" size="1">
					<option value="">MM
					<option value="1" >1<option value="2" >2<option value="3" >3<option value="4" >4<option value="5" >5<option value="6" >6<option value="7" >7<option value="8" >8<option value="9" >9<option value="10" >10<option value="11" >11<option value="12" >12			</select>
				<select style="width:55px;" class="smalltxt textbox" NAME="ylast" id="ylast" size="1">
					<option value="">YYYY
					<option value="2011" >2011<option value="2010" >2010<option value="2009" >2009<option value="2008" >2008<option value="2007" >2007<option value="2006" >2006<option value="2005" >2005<option value="2004" >2004<option value="2003" >2003<option value="2002" >2002<option value="2001" >2001<option value="2000" >2000<option value="1999" >1999<option value="1998" >1998<option value="1997" >1997<option value="1996" >1996<option value="1995" >1995<option value="1994" >1994<option value="1993" >1993<option value="1992" >1992<option value="1991" >1991<option value="1990" >1990<option value="1989" >1989<option value="1988" >1988<option value="1987" >1987<option value="1986" >1986<option value="1985" >1985<option value="1984" >1984<option value="1983" >1983<option value="1982" >1982<option value="1981" >1981<option value="1980" >1980<option value="1979" >1979<option value="1978" >1978<option value="1977" >1977<option value="1976" >1976<option value="1975" >1975<option value="1974" >1974<option value="1973" >1973<option value="1972" >1972<option value="1971" >1971<option value="1970" >1970<option value="1969" >1969<option value="1968" >1968<option value="1967" >1967<option value="1966" >1966<option value="1965" >1965<option value="1964" >1964<option value="1963" >1963<option value="1962" >1962<option value="1961" >1961<option value="1960" >1960<option value="1959" >1959<option value="1958" >1958<option value="1957" >1957<option value="1956" >1956<option value="1955" >1955<option value="1954" >1954<option value="1953" >1953<option value="1952" >1952<option value="1951" >1951<option value="1950" >1950			</select><br><font class="frmcomments">(optional)</font>
				</div>

				<div style="padding:0px 10px 10px 10px;"><span><font class="boldtxt">Hide Mobile Number<font class="formclr"></font>:</font></span><INPUT TYPE="checkbox" NAME="chkHideMobile" value="1" ></div>

				<!-- <div style="padding:10px;"><font class="boldtxt">Personal Message</font><br><font class="smalltxt">(Message from donor)</font> :<br><textarea rows=3 cols=30 name="about_me"  class="textbox"></textarea></div> -->
			</div>
			</div>
		</div>

	<div class="clear"></div>
	
	<div style="float:left;width:551px;border:1px solid #D7D7D7;">
		<div class="left" style="width:551px;">
				<div style="background: url(images/div-spheadbg-crv.gif);"><p style="padding-top:5px;padding-left:10px;"><font class="subheadtxt">Please check your eligibility to donate blood</font></p></div>
						<div class="left" style="width:541px;">
						
						
						<input type="hidden" name="suffered1[]" value="1" style="vertical-align:middle;"/>

						<div style="padding-left:30px;"><font color="#FF0000">#</font> <font class="frmcomments">Please consult your physician to check for eligibility.</font></div>
						<div style="padding:10px;"><input type="checkbox" name="suffered" value="YES" checked class="required">I have read the above eligibility criteria and confirm that I am eligible to donate blood.
						<br/>
						<input type="checkbox" name="suffered1" value="YES" checked /> I authorise the website to display my telephone number, e-mail ID and mailing address so that the needy could contact me, as and when there is an emergency.
						</div><br>


						<center><input type="submit" value=" Register " class="button"></center>

						</div>
				
		</div>
		</fieldset>
		</form>

<br>
	</div>
</div>
		
		</td>
		
		<td width="220" align="right">
		<? require "right.php";?>
		</td>
	</tr>
	</table>
	
<? include ("include/footer.php"); ?>