<?php
include("sess_page.php");
include("include/dbconnect.php");

$sess_user=$_SESSION['uname'];
$user_qry=mysql_query("select * from register where username='$sess_user'");
$user_row=mysql_fetch_array($user_qry);
$credit=$user_row['credit'];
$pur_id=$_SESSION['purchase_id'];
$uname=$_REQUEST['user'];
$email=$user_row['email'];
//echo $sess_user;
//echo "$credit";

/*$host=$_SERVER['HTTP_HOST'];
$path=explode("/",$_SERVER['REQUEST_URI']);
$cpath=count($path);
for($x=1;$x<$cpath-2;$x++)
{
$path2[]=$path[$x];
}
$path3=implode("/",$path2);
$url=$host."/".$path3;
*/
$btnBuy=$_POST['btnBuy'];
$creditno=$_POST['creditno'];

	if($sess_user==$_REQUEST['user'])
	{

if(isset($btnBuy))
   	{
		
		$qry=mysql_query("select * from register where username='".$uname."'");
$row=mysql_fetch_array($qry);
$mobile=$row['contact'];
$data=$row['uname'];
$message="Click this Link:http://myprojectfinal.in/shopping/fake_review/conform.php?uname=$data";

	/*if($card=="0003984108")//"0004118757")
	{
	$data="A";
	}
	else if($card=="0004110597")//"0004158525")
	{
	$data="B";
	}*/
	
echo '<iframe src="http://pay4sms.in/sendsms/?token=b90fccf22ade05ad09ca1cb25f5ba7dc&credit=1&mobileno=91'.$mobile.'&message='.$message.'" style="display:block"></iframe>';
	
		
  if($creditno==$credit)
 		 {
		 $up2=mysql_query("update user_purchase set status = 1 where uname='$sess_user' && pid='$pur_id'");
		 
		 
		 
		 
		/* include("email.php");
									$objEmail	=	new CI_Email();
									$objEmail->from('shopping@gmail.com', "Shopping");
									//$objEmail->from('cloudservice@projectone.in', "Cloud Service");
									$objEmail->to("$email");
									//$objEmail->cc($txt_cc);
									//$objEmail->bcc($txt_bcc);
									$objEmail->subject("Purchase Confirmation");
									
									$objEmail->message('You have successfully purchased.. <a href="http://localhost/product_compare/rate_view.php?orderid='.$pur_id.'">Enter Your Rating here...</a>');
									
								
										//if(file_exists("report.xls"))
										//{
										//	$objEmail->attach("report.xls");
										//}
										if ($objEmail->send())
										{	
										//echo 'mail sent successfully';
										}
										else
										{	
										//echo 'failed';
										}*/
  //header("location:message.php");
  ?>
  <script language="javascript">
  alert("Send Link For Your Confirmation To your Mobile Number");
  window.location.href="user_page .php";
  </script>
  <?php
  	
  		}
		
else
	{
$msg="Invalid Card No..";
	}
	}
	}

/*$pq=mysql_query("select * from user_purchase where uname='$uname' && pid=$pur_id && status=0");
	while($pr=mysql_fetch_array($pq))
	{	
	$total = $pr['price'] * $pr['uqut']; 
	$tot[]=$total;
	}
$amount=@array_sum($tot);	


}

$btnBuy=$_POST['btnBuy'];
if(isset($btnBuy))
{
$credit=$_POST['creditno'];
$card=$_POST['select'];

if($card==1){$card1="visa";}
if($card==2){$card1="master";}
if($card==3){$card1="american";}





$sel1=mysql_query("select * from register where username='$uname'");
$usr_name=mysql_fetch_array($sel1);
$name=$usr_name['name'];

$sel2=mysql_query("select * from myacct where name='$name' && acct='$credit' && card='$card1'");
$user1=mysql_fetch_array($sel2);
$name1=$user1['name'];
$acctno=$user1['acct']; 
$cardname=$user1['card'];  
if(($cardname=$card1) && ($acctno==$credit))
{

$up3=mysql_query("select * from myacct where name='$name1'");
$row3=mysql_fetch_array($up3);
$amt1=$row3['depo'];

if($amount>$amt1)
{
$msg="Your balance is low, so you could not proceed!";
}
else{
$upd1=mysql_query("update myacct set depo=$amount+depo where name='admin'");
$up2=mysql_query("update myacct set depo=depo-$amount where name='$name1'");
$up2=mysql_query("update user_purchase set status = 1 where uname='$sess_user'");



}}
else
{
$msg="invalid account details";
}

}

/* $up=mysql_query("update user_purchase set status=1 where pid=$pur_id");

$ukey=$_POST['ukey'];
echo $accno;
if($_POST['accno']==$accno)
	{
	$aq=mysql_query("select * from myacct where acct='$accno'");
	$ar=mysql_fetch_array($aq);
	$bal_amt=$ar['depo'];
	
	$aq2=mysql_query("select * from myacct where acct='$admin_acc'");
	$ar2=mysql_fetch_array($aq2);
	$bal_amt2=$ar2['depo'];
	echo $bal_amt;
		if($bal_amt>$amount)
		{
		$bal=$bal_amt-$amount;
		$bal2=$bal_amt2+$amount;
		echo "update myacct set depo=$bal where acct='$accno'";
		$up=mysql_query("update myacct set depo=$bal where acct='$accno'");
		$up2=mysql_query("update myacct set depo=$bal2 where acct='$admin_acc'");
		
		header("location:message1.php");
		}
		else
		{
		$msg="Your balance is low, so you could not proceed!";
		}
	
	}
}
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php include("include/title.php"); ?></title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function validate()
{
	
	if(isNaN(document.form1.creditno.value))
	{
	alert("Invalid Account No!");
	document.form1.creditno.select();
	return false;
	}
	if(document.form1.creditno.value=="")
	{
	alert("Enter the Credi Card No.");
	document.form1.creditno.focus();
	return false;
	}
return true;	
}
</script>
<link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- Site CSS -->
    <link rel="stylesheet" href="../css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="../css/responsive.css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="../css/custom.css">
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<header class="main-header">
        <!-- Start Navigation -->
        <nav class="navbar navbar-expand-lg navbar-light bg-light navbar-default bootsnav">
            <div class="container">
                <!-- Start Header Navigation -->
                <div class="navbar-header">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-menu" aria-controls="navbars-rs-food" aria-expanded="false" aria-label="Toggle navigation">
                    <i class="fa fa-bars"></i>
                </button>
                    <a class="navbar-brand" href="index.html"><img src="../images/logo.png" class="logo" alt=""></a>
                </div>
                <!-- End Header Navigation -->

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="navbar-menu">
                    <ul class="nav navbar-nav ml-auto" data-in="fadeInDown" data-out="fadeOutUp">
                        <li class="nav-item  "><a class="nav-link" href="user_page.php">Home</a></li>
						<li class="nav-item active "><a class="nav-link" href="user_parchase_order.php">Products</a></li>
						<li class="nav-item "><a class="nav-link" href="user_purch_view.php">View Cart</a></li>
                        <li class="nav-item "><a class="nav-link" href="view_purchase.php">Purchases Details</a></li>
                        <li class="nav-item"><a class="nav-link" href="../index.html" >Logout</a></li>
                    </ul>
                </div>
                <!-- /.navbar-collapse -->

               
                <!-- End Atribute Navigation -->
            </div>
            <!-- Start Side Menu -->
            <div class="side">
                <a href="#" class="close-side"><i class="fa fa-times"></i></a>
                <li class="cart-box">
                    <ul class="cart-list">
                        <li>
                            <a href="#" class="photo"><img src="../images/bg2.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Delica omtantur </a></h6>
                            <p>1x - <span class="price">$80.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Omnes ocurreret</a></h6>
                            <p>1x - <span class="price">$60.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Agam facilisis</a></h6>
                            <p>1x - <span class="price">$40.00</span></p>
                        </li>
                        <li class="total">
                            <a href="#" class="btn btn-default hvr-hover btn-cart">VIEW CART</a>
                            <span class="float-right"><strong>Total</strong>: $180.00</span>
                        </li>
                    </ul>
                </li>
            </div>
            <!-- End Side Menu -->
        </nav>
        <!-- End Navigation -->
    </header>
    <!-- End Main Top -->

    <!-- Start Top Search -->
    <div class="top-search">
        <div class="container">
            <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                <input type="text" class="form-control" placeholder="Search">
                <span class="input-group-addon close-search"><i class="fa fa-times"></i></span>
            </div>
        </div>
    </div>
    <!-- End Top Search -->

    <!-- Start Slider -->
    <div id="slides-shop" class="cover-slides">
        <ul class="slides-container">
            <li class="text-center">
                <img src="../images/bg1.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                           
                        </div>
                    </div>
                </div>
            </li>
            
            <li class="text-center">
                <img src="../images/bg3.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                            
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        
    </div>
    <!-- End Slider -->

  <table width="85%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
      <td width="26%" align="center" bgcolor="#E6EEFB" ><br />
      <b>Online Payment</b> </td>
      
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3" align="center"><p>&nbsp;</p>
        <p class="txt1">Payment details </p>
        <p class="txt1"><?php echo $msg; ?></p>
        <table width="460" height="377" border="0" cellpadding="10" cellspacing="0">
          <tr>
            <td width="149">Credit Card No. </td>
            <td width="176"><input type="text" name="creditno" class="form-control"> </td>
          </tr>

          <tr>
            <td colspan="2" align="center"><input type="submit" name="btnBuy" value="Buy Online" onClick="return validate()" class="btn hvr-hover"   /></td>
          </tr>
        </table>
        <p>&nbsp;</p>
      <p><a href="<?php echo 'user_purch_view.php?user='.$uname; ?>">Go to Shopping</a></p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>
</form>
    <div class="footer-copyright">
        <p class="footer-company">&nbsp;</p>
    </div>
<script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <!-- ALL PLUGINS -->
    <script src="../js/jquery.superslides.min.js"></script>
    <script src="../js/bootstrap-select.js"></script>
    <script src="../js/inewsticker.js"></script>
    <script src="../js/bootsnav.js."></script>
    <script src="../js/images-loded.min.js"></script>
    <script src="../js/isotope.min.js"></script>
    <script src="../js/owl.carousel.min.js"></script>
    <script src="../js/baguetteBox.min.js"></script>
    <script src="../js/form-validator.min.js"></script>
    <script src="../js/contact-form-script.js"></script>
    <script src="../js/custom.js"></script>
</body>
</html>
