<?php 
    include "Admin/config/setup.php" ;
    $mobile = $_POST['mobile'];
    $check_sql = "SELECT * FROM master_login WHERE Master_phone = '$mobile' AND Master_Type = 3 ";
    $check_res = $config->query($check_sql) ;
    if($check_res->num_rows > 0){ 
        $check_row = $check_res->fetch_assoc();
        $id = $check_row['Master_id'] ;
        $wal_sql = "SELECT * FROM ewallet_master WHERE user_id = '$id' ";
        $wal_res = $config->query($wal_sql) ;
        $wal_row = $wal_res->fetch_assoc();
    ?>
    <form method="post">
		<!-- Basic Information -->
				<div class="row form-row">
					<div class="col-md-6">
						<div class="form-group">
							<label>Mobile Number <span class="text-danger">*</span></label>
							<div class="input-group mb-3">
                                <input type="number" class="form-control" name="phone" id="phone" value="<?= $mobile ?>" maxlength="10" >
                                <div class="input-group-append">
                                  <span type="button" class="input-group-text btn btn-primary submit-btn"  id="search-phone" >Submit</span>
                                </div>
                            </div>
							<div><?= 'Name : '.$check_row['Master_Name'].' , Wallet Balance : '.$wal_row['total_amount'] ?></div>
						</div>
					</div>
					<div class="col-md-6" >
						<div class="form-group">
            				<label>Amount<span class="text-danger">*</span></label>
            				<div class="input-group mb-3">
                                <input type="number" class="form-control" name="swap_amount" id="swap_amount">
                                <input type="hidden" class="form-control" name="swap_to" value="<?= $check_row['Master_id'] ?>">
                                <div class="input-group-append">
                                  <button type="submit" class="input-group-text btn btn-primary submit-btn" name="swap">Swap</button>
                                </div>
                            </div>
            			</div>
					</div>
		
				</div>
		    
			<!-- /Basic Information -->

	</form>
    	   
   <?php }else{?>
        <form method="post" enctype="multipart/form-data">
		<!-- Basic Information -->
			<div class="row form-row">
				<div class="col-md-6">
					<div class="form-group">
						<label>Mobile Number <span class="text-danger">*</span></label>
						<div class="input-group mb-3">
                            <input type="number" class="form-control" name="phone" id="phone" value="<?= $mobile ?>" maxlength="10" >
                            <div class="input-group-append">
                              <span type="button" class="input-group-text btn btn-primary submit-btn"  id="search-phone" >Submit</span>
                            </div>
                        </div>
						<span class="text-danger py-2">Not Found</span>
					</div>
				</div>
			</div>
			<!-- /Basic Information -->
		</form>
<?php } ?>