$req_login=false;
include "framework.php";
$pwd_codes="
";
$pwd_id=6;
$university_name="University of Calcutta";
$caste_options="
";
$hs_year=date("Y");
$query_result = mysqli_query($connection,"select hs_year from c_preferences");
while($qdata = mysqli_fetch_array($query_result))
{
$hs_year=$qdata['hs_year'];
}
$pass_year_options="";
for($i=date("Y"); $i>=$hs_year; $i--)
{
$pass_year_options.="";
}
$adm_start=$adm_end=0;
$query_result = mysqli_query($connection,"select * from c_admission_open");
while($qdata = mysqli_fetch_array($query_result))
{
$adm_start=$qdata['start_from'];
$adm_end=$qdata['end_on'];
}
$phase_id=0;
$phase_title="";
$query_result = mysqli_query($connection,"select max(id),phase_title from x_phases where allow_new=1");
while($qdata = mysqli_fetch_array($query_result))
{
$phase_id=$qdata[0];
$phase_title=stripslashes($qdata['phase_title']);
}
$dd=$mm=$yyyy="";
for($i=1;$i<=31;$i++)
{
$j="";
if($i<10){$j="0";}
$dd.="";
}
for($i=1;$i<=12;$i++)
{
$j="";
if($i<10){$j="0";}
$mm.="";
}
for($i=2007;$i>=1980;$i--)
{
$yyyy.="";
}
$otp_req=false;
if($h_action=="register" && $phase_id>0)
{
$fullname=addslashes(trim($_REQUEST['fullname']));
$mobile=addslashes(trim($_REQUEST['mobile']));
$email=addslashes(trim($_REQUEST['email']));
$rollnum=addslashes(trim($_REQUEST['rollnum']));
$dob=$_REQUEST['mm1']."/".$_REQUEST['dd1']."/".$_REQUEST['yyyy1'];
$dob_ts=strtotime($_REQUEST['mm1']."/".$_REQUEST['dd1']."/".$_REQUEST['yyyy1']." 10:00:00");
$just_year_dob=intval($_REQUEST['yyyy1']);
$just_year_now=intval(date("Y"));
$pass_year=intval($_REQUEST['pass_year']);
$bssno=addslashes(trim($_REQUEST['bssno']));
$coursetype=addslashes(trim($_REQUEST['coursetype']));
//if($_POST['already_exam']=="YES"){$error_msg="Sorry, those who have appeared in examination under $iniversity_name cannot register here.";}
if($just_year_now-$just_year_dob<15){$error_msg="Sorry, you must be of age 15 years or more.";}
$dup=false; $dups[0]="unpaid"; $has_paid=false;$dup_id=0;
$dup_what="";
$query_result = mysqli_query($connection,"select id,mobile_num,email from a_applications where (mobile_num='$mobile') or (email<>'' and email='$email')");
while($qdata = mysqli_fetch_array($query_result))
{
$dup_id=$qdata['id'];
$dup=true;
if($qdata['mobile_num']==$mobile)
{
$dup_what="mobile number";
}
else
{
$dup_what="email address";
}
}
$new_otp=generate_new_otp(6,$connection);
//$new_otp="506274";
//echo "New OTP is $new_otp
";
if($dup)
{
header("Location: duplicate_error.php?dup_type=".$dup_what);
}
else
{
if($error_msg!="" || $fullname=="" || $mobile=="" || $dob=="" || $error_msg!="" || $pass_year<=0 || $email=="")
{
if($fullname==""){$error_msg="You must enter your full name.";}
if($mobile==""){$error_msg.=" A valid 10 digit mobile number is required.";}
if($email==""){$error_msg.=" A valid email address is required.";}
if($dob==""){$error_msg.=" Date of Birth can't be blank.";}
if($pass_year<=0){$error_msg.=" You have not entered year of passing.";}
}
else
{
$college_timing_id=0;
$query_result = mysqli_query($connection,"select id from c_college_timings");
while($qdata = mysqli_fetch_array($query_result))
{
$college_timing_id=$qdata['id'];
}
$uni_adm=$uni_reg=$uni_exam=0;$uni_reg_num="";
if($_POST['already_adm']=="YES"){$uni_adm=1;}
if($_POST['already_adm']=="YES" && $_POST['already_reg']=="YES"){$uni_reg=1;$uni_reg_num=addslashes($_POST['uni_reg_num']);}
if($_POST['already_adm']=="YES" && $_POST['already_reg']=="YES" && $_POST['already_exam']=="YES"){$uni_exam=1;}
$pwd_pctg=floatval(str_replace("%","",$_POST['pwd_pctg']));
$pwd_code=addslashes($_POST['pwd_code']);
$app_year=date("Y");
mysqli_query($connection,"insert into a_applications set application_year='$app_year',phase_id=$phase_id,college_timing_id='$college_timing_id',
full_name='$fullname',mobile_num='$mobile',email='$email',dob=$dob_ts,uni_adm='$uni_adm',
uni_reg='$uni_reg', uni_reg_num='$uni_reg_num', uni_exam='$uni_exam', pwd_pctg='$pwd_pctg',pwd_code='$pwd_code',add_ts=$now,update_u=0,bangla_shiksha='$bssno',course_type='$coursetype'");
$aid=mysqli_insert_id($connection);
mysqli_query($connection,"insert into a_applications_hs set application_id=$aid,roll_num='$rollnum',year_of_passing=$pass_year");
$res=intval($_POST['res_cat']);
$res_aid=0;
if($res==1 || $res==2 || $res==3 || $res==4 || $res==7)
{
if($_POST['sc_st_obc_wb']=="YES"){$res_aid=1;}
$sc_st_obc_card_num=addslashes($_POST['sc_st_obc_card_num']);
if($res==3 || $res==4 || $res==7){if($_POST['obc_income']!="YES"){$res_aid=0;}}
mysqli_query($connection,"insert into a_applications_reservations set application_id=$aid,reservation_id=$res,auth_id=$res_aid");
mysqli_query($connection,"update a_applications set sc_st_obc_card_num='$sc_st_obc_card_num' where id=$aid");
}
if($_POST['pwd']=="YES")
{
if($pwd_pctg>=40 && $pwd_code!="")
{
mysqli_query($connection,"insert into a_applications_reservations set application_id=$aid,reservation_id=$pwd_id,auth_id=1");
}
else
{
mysqli_query($connection,"insert into a_applications_reservations set application_id=$aid,reservation_id=$pwd_id,auth_id=0");
}
}
$cur_applicant['id']=$aid;
$cur_applicant['name']=stripslashes($fullname);
$cur_applicant['email']=stripslashes($email);
$cur_applicant['phone']=stripslashes($mobile);
$mem_key=md5($aid.$mobile.$email.$now.$_SERVER['REMOTE_ADDR']);
$ip_key=md5($_SERVER['REMOTE_ADDR']);
setcookie($mem_key, $ip_key, time() + (86400 * 30), "/");
mysqli_query($connection,"insert into x_applicants_login_keys values(null,$aid,$now,'$mem_key','$ip_key')");
$new_key_id=mysqli_insert_id($connection);
if($otp_req)
$otp_matched=0;
else
$otp_matched=1;
mysqli_query($connection,"insert into x_applicants_login_otps set key_id=$new_key_id,otp='$new_otp',is_matched=$otp_matched");
if($otp_req)
{
sms_otp($aid,$new_otp,$connection);
//echo "i am here (2)....
";
}
header("Location: apply_page_3_status.php?mk=".$mem_key);
}
}
}
$red_star="*";
$apply_active="active";
?>