<?php

    error_reporting(E_ALL);
    $status="fail";
	include_once('../includes/connect_database.php'); 
	include_once('../includes/variables.php');
	

	
// 	 $mdata=isset($_POST['data'])?$_POST['data']:'no data';

//$fp = fopen("../api/1.txt","wb");
//fwrite($fp,$mdata );
//fclose($fp);
//exit;
        
         $status="fail";
      // $mdata = json_decode($mmdata,true);
    //   $data=json_decode($mdata,true);	
       
    /* form data */
	//$data = json_decode(trim(file_get_contents('php://input')), true);
	
    $mdata=isset($_POST['data'])?$_POST['data']:'no data';
    $data=json_decode($mdata,true);

	
    $student_name = isset($data['student_name'])?$data['student_name']:'';
	$student_dob = isset($data['student_dob'])?date('Y-m-d',strtotime($data['student_dob'])):'';
	$mobile = isset($data['mobile'])?$data['mobile']:'';
	$email = isset($data['email'])?$data['email']:'';
	$guardian = isset($data['guardian'])?$data['guardian']:'';
	$cemail=$email;
	$mobile_guardian = isset($data['mobile_guardian'])?$data['mobile_guardian']:'';
	$email_guardian = isset($data['email_guardian'])?$data['email_guardian']:'';
	$address = isset($data['address'])?$data['address']:'';
	$city = isset($data['city'])?$data['city']:'';

    	
    	
    

	$ten_board = isset($data['ten_board'])?$data['ten_board']:'';
	$ten_studyyear = isset($data['ten_studyyear'])?$data['ten_studyyear']:'';
	$ten_schoolname = isset($data['ten_schoolname'])?$data['ten_schoolname']:'';
	$ten_marks = isset($data['ten_marks'])?$data['ten_marks']:'';
	$twelve_studyyear = isset($data['twelve_studyyear'])?$data['twelve_studyyear']:'';
	$twelve_marks = isset($data['twelve_marks'])?$data['twelve_marks']:'';
	$twelve_board = isset($data['twelve_board'])?$data['twelve_board']:'';

	$state= isset($data['state'])?$data['state']:'';
	$other = isset($data['other'])?$data['other']:'';
	$twelve_result = isset($data['twelve_result'])?$data['twelve_result']:'';
	$course = isset($data['course'])?$data['course']:'';
			$mode = isset($data['mode'])?$data['mode']:'';
	$looking_for_scholarship = isset($data['looking_for_scholarship'])?$data['looking_for_scholarship']:'';
		$twelve_schoolname= isset($data['twelve_schoolname'])?$data['twelve_schoolname']:'';
	

	
	
	
	$sql_query = "INSERT INTO tbl_student(student_name,student_dob,mobile,email,guardian,mobile_guardian,email_guardian,
		address,city,state,other,ten_board,ten_studyyear,ten_schoolname,ten_marks,twelve_studyyear,
		twelve_schoolname,twelve_marks,twelve_board,twelve_result,course,mode,looking_for_scholarship,created) 
					VALUES ('".$student_name."',
					        '".$student_dob."',
					        '".$mobile."',
					        '".$email."',
					        '".$guardian."',
					        '".$mobile_guardian."',
					        '".$email_guardian."',
		                    '".$address."',
		                    '".$city."',
		                    '".$state."',
		                    '".$other."',
		                    '".$ten_board."',
		                    '".$ten_studyyear."',
		                    '".$ten_schoolname."',
		                    '".$ten_marks."',
		                    '".$twelve_studyyear."',
		                    '".$twelve_schoolname."',
		                    '".$twelve_marks."',
		                    '".$twelve_board."',
		                    '".$twelve_result."',
		                    '".$course."',
		                    '".$mode."',
		                    '".$looking_for_scholarship."',
		                    '".date('Y-m-d')."')";
	
	 $result = mysqli_query($connect, $sql_query);
	
	
	
	$order_id =  mysqli_insert_id($connect);

	
	 
	$passid='';
	if(isset($order_id) && $order_id)
	{
		$passid="FW202023".str_pad($order_id,3,'0',STR_PAD_LEFT);
	}
	$d=array('status'=>"success",'id'=>$passid);
 echo json_encode($d);exit;
	include_once('../includes/close_database.php');
?>