	<?php
	/**
	* Created by PhpStorm.
	* User: ahmad
	* Date: 20/08/2019
	* Time: 11:48 AM
	*/

	require_once("../connection.php");
	
	$key=mysqli_real_escape_string($connect, $_POST['key']);
	$nama_bank=mysqli_real_escape_string($connect, $_POST['nama_bank']);
	$atas_nama=mysqli_real_escape_string($connect, $_POST['atas_nama']);
	$norek=mysqli_real_escape_string($connect, $_POST['norek']);

	$getusers = mysqli_query($connect,"SELECT * FROM users WHERE id_session='$key'");
	$u	      = mysqli_fetch_array($getusers);
	$jumlah   = mysqli_num_rows($getusers);
	
	$masterakun = mysqli_query($connect,"SELECT * FROM users WHERE no_telp='$u[master]'");
	$m=mysqli_fetch_array($masterakun);


	if ($jumlah > 0){

	mysqli_query($connect,"INSERT INTO bank(nama_bank, atas_nama, norek,
                                  user) 
                    VALUES('$nama_bank', '$atas_nama', '$norek',
                           '$m[no_telp]')");



	
	
	$json = array(
    'status' 	=> 'true',
    'errCode' 	=> '01',
	'msg' 		=> 'Success'
	);

    echo json_encode($json);

	}else{
	
	
	$json = array(
    'status' 	=> 'true',
    'errCode' 	=> '00',
	'msg' 		=> 'User Not Found'
   );

    echo json_encode($json);	
	}
	?>