从PayPal成功返回时上传的文件名保存在数据库中


Uploaded file name save in database when return from paypal successfully

我有一个表单,通过该表单处理购物车数据,并在点击按钮上处理PayPal。我制作了一个success.php页面,当交易完成时会自动返回。所有字段都已成功保存在数据库中,但我被用户将上传的文件所困扰。我的问题是,当结帐成功返回到success.php页面时PayPal有没有办法将上传的文件名保存在数据库中,如果是这样,那么如何在PayPal按钮内传递变量?我已经对此进行了多次搜索。但是没有人帮助我的问题。任何建议或指导将不胜感激。形式.php

     <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"  enctype="multipart/form-data">
      <!-- Identify your business so that you can collect the payments. -->
   <input type="hidden" name="business" value="sriniv_1293527277_biz@inbox.com">
   <!-- Specify a Buy Now button. -->
   <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="upload" value="1">
    <input type="file" name="custom" >
     <Label> Select shipment interval (optional):
     <select id="shipment_option" name="shipment">
      <option  selected="selected" value="7" id="7">7</option>
      <option value="6" id="6"> 6 </option>
       <option value="5" id="5">5 </option>
        </select></Label>
    <input type="hidden" name="return" value="success.php">
     <input type="hidden" name="cancel_return" value="paypal_cancel.php">
    <input type="image" name="submit" border="0" src="LG.gif">
    </form>

成功.php

<?php
session_start();
include("db/db.php");
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>
<html>
<title>Success</title>
<body>
<?php
if(isset($_SESSION['cart']) && isset ($_SESSION['login_email'])){
$total=0;
$email=$_SESSION['login_email'];
$ships=$_POST['shipment'];
$file=$_FILES['file']['custom'];//this is how i am  trying to get the file name. But it doesnot work
//customer information
$query1=mysqli_query($con,"select * from customers where email='$email'");
while($rows=mysqli_fetch_array($query1,MYSQLI_ASSOC))
{
$user=$rows['name'];
$user_id=$rows['serial'];
}
 //orders and order details.
$que=mysqli_query($con,"insert into orders(custom_file,date,customerid,status,ship_days) values('$file',CURRENT_TIMESTAMP(),'$user_id','confirmed','$ships')");
if($que)
{
$m=move_uploaded_file($_FILES['file']['name'],'./ServerUploadedFiles/'.$user.$file);
$q=mysqli_query($con,"select serial from orders where customerid='$user_id' and date=CURRENT_TIMESTAMP()");
while($row1=mysqli_fetch_array($q,MYSQLI_ASSOC))
{
$order_id=$row1['serial'];
}
foreach($_SESSION['cart'] as $id => $value){
$subtotal=$value['price']*$value['quantity'];
$pid=$value['id'];
$quantity=$value['quantity'];
$color=$value['color'];
$size=$value['size'];
$total+= $subtotal;
$query= mysqli_query($con, "INSERT INTO order_detail(orderid,productid,quantity,price,color,size) VALUES ($order_id, $pid, $quantity, $subtotal, '$color', '$size')");
}

}
//payment details for paypal
    $amount=$_GET['amt'];
    $currency=$_GET['cc'];
    $trx_id=$_GET['tx'];
    $insert_payments= mysqli_query($con,"insert into payments(amount,cust_id,order_id,trx_id,currency) values('$amount','$user_id','$order_id','$trx_id','$currency')");
    if($amount==$total)
    {
       unset($_SESSION['cart']);
       echo "<h2>Hello". $user."You have successfully done purchasing process.Please <a href='profile.php'>Go to your account</a>!</h2>";
    }
    else
    {
        echo "<h2>Hello". $user."Your payment was not successful.Please <a href='profile.php'>Go to your account</a>!</h2>";
    }
   }
?>
 </body>
</html>
您可以使用

PayPal的"custom"变量将其传递给PayPal,它也将在发布回您的网站时返回给您。 买方也不会在他们这边看到这个变量。