Insert form details to database and then redirect to Paypal using javascript in php

<!--insert into database-->
<?php 
if(isset($_POST['submit'])){
$email=$_POST['email'];
$amount=$_POST['amount'];
$sql = "INSERT INTO payment(emailid , pay_amount) VALUES('".$email."','".$amount."')"; 
$result=$mysqli_query($conn, $sql);
}
?>

<!--form-->
<form method="post" action="">
<input type="email" name="email">
<input type="text" name="amount">
<button name="submit">Pay</button>
<?form>

<!--paypal form-->
<form id="paypal_submit_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr"  method="post">
<input type="hidden" name="add" value="1">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="yourbusinessid@b.com">
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="action" value="formaction">
<input type="hidden" name="email" id="emailid"  value="<?php echo $_POST['email'];?>" >
<input type="hidden" id="amountid" name="amount"  value="<?php echo $_POST['amount'];?>" >
</form>

<!--Javascript-->
<script type="text/javascript">
document.getElementById("paypal_submit_form").submit();
</script>
Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone