<?php session_start();  //Developed by ITechScripts
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch
?>
<?
if(isset($_REQUEST['continue']))
{
  echo "mef".$pay_method=$_REQUEST['pay_method'];
  $pm=$_SESSION['current_price'];
  $productid=$_REQUEST[productid];  

   if($pay_method=="payment_gateway")
   {
    echo "<meta http-equiv='refresh' content=0;url=postpayment.php?>";
	exit();
   }
   else if($pay_method=="myaccount")
   {
    $type=$_REQUEST['pay_type'];
	$buyer_id=$_SESSION['userid'];
	 $sql="select * from auction_details where productid=".$productid;
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result);
	$user_id=$row[user_id];
	$query="select * from  where user_id='$buyer_id'";
	$table=mysql_query($query);
	if(mysql_num_rows($table)>0)
	$row=mysql_fetch_array($table);
   	$total_amount=$row['fund_amount'];
	$date=date("Y:m:d");
	echo $total_amount;
	echo "p".$pm;
	if($pm<=$total_amount)
	{  
	  $fundquery="insert into addfunds(member_id,fund_amount,fund_date,fund_thru,buyer_id)                                            values('$user_id','$pm','$date',$pay_method,$buyer_id)";
	  mysql_query($fundquery);
	  $acc_sql="select * from myaccount where user_id=".$buyer_id;
	  $exit_acc=mysql_query($acc_sql);
	  if(mysql_num_rows($exit_acc)>0)
	  {
	  	  $update_acc_sql="update myaccount set amount=amount-$pm where user_id=".$buyer_id;
		  
	   }	  
	  else
	  {
	      $update_acc_sql="update myaccount set amount=amount+$pm where user_id=".$buyer_id;
	  }  	  
	     mysql_query($update_acc_sql);
	  echo "<meta http-equiv='refresh' content=0;url=myauction.php? >";
	  exit();
	}
	else
	{ 	
$error=$err_6;
//	  $error="Your Account is too low then you expect.";
	}
	}
	   
	
   }
//}
require 'themes/paynow.tpl';
?>
<script >
function myaccount(val)
{
if(val==1)
{
content="<table  align=center ><tr><td>";
content+="<input type=radio name=pay_type value=balance checked><strong> Buy Using Balance.</td></tr>";
content+="<tr><td> <input type=radio name=pay_type value=referral ><strong> Buy Using Referral Income. </td><tr>"
content+="</table>";
}
if(val==2)
{
content="";
}

my.innerHTML=content;
}
</script>
</body>
</html>