<?php
echo "hello";exit;
$status="fail";
	include_once('../includes/connect_database.php'); 
	include_once('../includes/variables.php');
		
         $mdata=isset($_POST['data'])?$_POST['data']:'no data';
        
         $status="fail"
      // $mdata = json_decode($mmdata,true);
$data=json_decode($mdata,true);
//echo $mmdata->{'address'};
//exit;
        //$yummy = json_decode($json);
//echo "hhhh";
      //   echo $mdata;
         //exit;
        // $data->addre
        // echo "jjjj".$data;exit;
        // $1obj=json_decode($mmdata);
         //1print $obj;
	//print_r($data);
//   //exit;// get data from android app
//	$data=$mdata['data'];
	//print_r($data);exit;
	$student_name = isset($data['address'])?$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']:'';

	$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']:'';
					
$created=date('Y-m-d');
   $sql_query = "set names 'utf8'";
   $created=date('Y-m-d H:i:s');
	$stmt = $connect->stmt_init();
	if($stmt->prepare($sql_query)) {	
		// Execute query
		$stmt->execute();
		// store result 
		$stmt->close();
	}
	$torder='<html><body><table table rules="all" style="border-color: #666;" cellpadding="10" style="width:100%;border:1px;"><tr>';
	// insert data into reservation table
	$sql_query = "INSERT INTO tbl_student(student_name,student_dob,mobile,email,guardian,mobile_guardian,email_guardian,
		address,city,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 (?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	
	$stmt = $connect->stmt_init();
	if($stmt->prepare($sql_query)) {	
		// Bind your variables to replace the ?s
		$stmt->bind_param('sssssssssssssssssssss', 
					$student_name,$student_dob,$mobile,$email,$guardian,$mobile_guardian,$email_guardian,
		$address,$city,$ten_board,$ten_studyyear,$ten_schoolname,$ten_marks,$twelve_studyyear,
		$twelve_schoolname,$twelve_marks,$twelve_board,$twelve_result,$course,$mode,$looking_for_scholarship,$created);
		// Execute query
		$stmt->execute();
		$result = $stmt->affected_rows;
		// store result 
		if($result)
		{
			$status="success";
		
}
		
		//$result = $stmt->store_result();
		$stmt->close();
	}
	
	// get admin email from user table
	/*$sql_query = "SELECT Email 
			FROM tbl_user";
	
	$stmt = $connect->stmt_init();
	if($stmt->prepare($sql_query)) {	
		// Execute query
		$stmt->execute();
		// store result 
		$stmt->store_result();
		$stmt->bind_result($email);
		$stmt->fetch();
		$stmt->close();
	}
	*/
	// if new reservation has been successfully added to reservation table 
	$d=array('status'=>$status);
 echo json_encode($d);exit;
	include_once('../includes/close_database.php');
?>