php - Uploaded file name save in database when return from paypal successfully -
i have form through cart data processed , onclick button processes paypal. have made success.php page auto return when transaction completed. fields saving in db stuck file user upload. question is, there way save uploaded file name in database when paypal checkout returns success.php page , if so, how can pass variable within paypal button? have go through many searches regarding this. none helped issue. suggestions or guide appreciated. form.php
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" enctype="multipart/form-data"> <!-- identify business can collect payments. --> <input type="hidden" name="business" value="sriniv_1293527277_biz@inbox.com"> <!-- specify buy 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> success.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 how trying file name. doesnot work //customer information $query1=mysqli_query($con,"select * customers email='$email'"); while($rows=mysqli_fetch_array($query1,mysqli_assoc)) { $user=$rows['name']; $user_id=$rows['serial']; } //orders , order details. $que=mysqli_query($con,"insert 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 orders customerid='$user_id' , date=current_timestamp()"); while($row1=mysqli_fetch_array($q,mysqli_assoc)) { $order_id=$row1['serial']; } foreach($_session['cart'] $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 order_detail(orderid,productid,quantity,price,color,size) values ($order_id, $pid, $quantity, $subtotal, '$color', '$size')"); } } //payment details paypal $amount=$_get['amt']; $currency=$_get['cc']; $trx_id=$_get['tx']; $insert_payments= mysqli_query($con,"insert 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 done purchasing process.please <a href='profile.php'>go account</a>!</h2>"; } else { echo "<h2>hello". $user."your payment not successful.please <a href='profile.php'>go account</a>!</h2>"; } } ?> </body> </html>
you can use paypal's "custom" variable pass on paypal, , returned in post site. buyer's wont see variable on end.
Comments
Post a Comment