paypal form
<form action='https://www.paypal.com/donate' method='post' target='_top'>
<!-- Paypal business test account email id so that you can collect the payments. -->
<input type='hidden' name='business' value='YOUR_PAYPAL_EMAIL_ID'>
<!-- Buy Now button. -- _xclick>
<input type='hidden' name='cmd' value='_donations'>
<!-- Details about the item that buyers will purchase. -->
<input type='hidden' name='item_name' value='$sql[donate_for]'>
<input type='hidden' name='item_number' value='$sql[order_id]'>
<input type='hidden' name='amount' value='$sql[amount]'>
<input type='hidden' name='currency_code' value='USD' readonly>
<!-- URLs -->
<input type='hidden' name='cancel_return' value='https://localhost/donate-us.php'>
<input type='hidden' name='return' value='https://localhost/success.php'>
<!-- payment button. -->
<!--input type='image' name='submit' border='0'
src='https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif' alt='Donate'>
<img alt='' border='0' width='1' height='1' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' -->
<button class='theme-btn btn-style-one' type='submit' name='submit'><span>Donate with Paypal</span></button>
</form>
Success.php
<h1>Your payment has been successful.</h1>
<?php
error_reporting(1);
include_once("connect.php");
//Store transaction information into database from PayPal
$item_number = $_GET['item_number'];
$txn_id = $_GET['tx'];
$payment_gross = $_GET['amt'];
$currency_code = $_GET['cc'];
$payment_status = $_GET['st'];
//Get product price to store into database
$sql = "SELECT * FROM donate_us WHERE order_id = ".$item_number;
$resultset = mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));
$row = mysqli_fetch_assoc($resultset);
if(!empty($txn_id) && $payment_gross == $row['price']){
//Insert tansaction data into the database
// mysqli_query($conn, "INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");
mysqli_query($conn, "UPDATE donate_us SET pay_id = '$txn_id',payment_status = 'Done' WHERE WHERE order_id = '$item_number'");
$last_insert_id = mysqli_insert_id($conn);
?>
<h1>Your payment has been successful.</h1>
<h1>Your Payment ID - <?php echo $last_insert_id; ?>.</h1>
<h1>Your Payment txn ID - <?php echo $txn_id; ?>.</h1>
<?php
}else{
?>
<h1>Your payment has failed.</h1>
<?php
}
?>