<?php 
include ('database.php');
session_start();


if(isset($_POST['submit']));
{
    
    $id = mysqli_real_escape_string($connection, $_POST['id']);
	$number = mysqli_real_escape_string($connection, $_POST['number']);
	$amount = mysqli_real_escape_string($connection, $_POST['amount']);
 
	
   $verify_query = "SELECT identification, balance, id FROM users WHERE id='$id' LIMIT 1";
   $verify_query_run = mysqli_query($connection, $verify_query);

   if(mysqli_num_rows($verify_query_run) > 0)
   { 
      $row = mysqli_fetch_array($verify_query_run);
	  $identification = $row['identification'];
	  
	  if($identification == "1")
	  {
	$bb= $row['balance'];
      if($bb > $amount || $bb == $amount)
      {
	  $query = "SELECT number, fname, lname, balance, id FROM users WHERE number='$number' LIMIT 1";
      $query_run = mysqli_query($connection, $query);
      if(mysqli_num_rows($query_run) > 0)
      { 
      $brow = mysqli_fetch_array($query_run);
	  $sid = $brow['id'];
	  $snumber = $brow['number'];
      $slname = $brow['lname'];
	  $sfname = $brow['fname'];
	  $_SESSION['sfname'] = $sfname;
	  $_SESSION['slname'] = $slname;
	  $_SESSION['snumber'] = $snumber;
	  $_SESSION['sid'] = $sid;
	  $_SESSION['amount'] = $amount;
	  header("location:../send2.php"); 
 }
 else
 {
	  $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Service Down Try Again Later</h5>";
       
	header("location: ../send.php");  
 }
	  }
      else{
		  $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Insuficient Fund</h5>";
       
	header("location: ../send.php"); 
	  }
   }
   else{
	 $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Invalid Goldlinebanking Account Number</h5>";
       
	header("location: ../send.php");  
}
}
   else{
	 $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Service Down Try Again Later</h5>";
       
	header("location: ../send.php");  
}
}
?>