Click here to Skip to main content
15,888,119 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have these files that are made to start a transaction via paypal with a dinamic price based on the user choices.
 <script language="javascript">
       submitForms = function(){
       document.getElementById("paypal2_form").submit();
       document.getElementById("paypal_form").submit();
     }

</script>
<form class="paypal" action="payments.php" method="post" id="paypal2_form" target="_blank">
    <input type="text" name="amount" value=""/>
    <input type="button" value="Click Me!" onclick="submitForms()" />
</form>
<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_blank">
    <input type="hidden" name="cmd" value="_xclick" />
    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="lc" value="UK" />
    <input type="hidden" name="currency_code" value="GBP" />
    <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
    <input type="hidden" name="first_name" value="Customer's First Name"  />
    <input type="hidden" name="last_name" value="Customer's Last Name"  />
    <input type="hidden" name="payer_email" value="customer@example.com"  />
    <input type="hidden" name="item_number" value="123456" / >
</form>

And this is the php.

 // Database variables
$host = "localhost"; //database location
$user = "root"; //database username
$pass = ""; //database password
$db_name = "payments"; //database name
$paypal_email = 'myemail';
$return_url = 'return page.org';
$cancel_url = 'cancel page.org';
$notify_url = 'notify page.org';

$xd = $_POST['amount'];

$item_name = 'Test Item';
$item_amount = 10;
...

The thing is that $item_aamount, if I put the exact value it will work but if i use the variable with the value that comes from the form it will ask on the paypal window to insert the value.I tought on the html page insert the value on the database and ask for it on this php but i dont know what to put the transaction_id , field i dont know where it comes from.

(On the html page i have a script that submits the 2 forms one with the value other with the paypal things , its a text input because its a test to make the paypal eat the goddam value from the variable).

If there is a better way to do it rather than this im open.Thx in advance

What I have tried:

I already tried to put the value in a database and get the go get the value on the other page
Posted
Updated 16-May-17 0:45am

1 solution

Why do you have two separate forms? You submit them both but why do you expect the value from one form to be transferred to another or even get through at all? Having the same name doesn't do it: they're two separate instances.

Ways to make it work:
Put everything in one form so all data gets to server together!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900