title: PHP/Ajax collect and pass form data
body: <p>I need to collect an input ('x_amount') with a php form, then post it to a page that generates a hash and then posts it to a third party site.  I don't want the customer to have a two step process, so can this be done with ajax and php?  Here's what I have so far, but it needs to be ajaxified (i think?)</p>
  
  <pre><code>          &lt;form action="https://globalgatewaye4.firstdata.com/pay" method="POST"&gt;
  
          &lt;?php
                $x_login = "xxx-xxx";  //  Take from Payment Page ID in Payment Pages interface
                $transaction_key = "xxxxxxx"; // Take from Payment Pages configuration interface
                $x_currency_code = "CAD"; // Needs to agree with the currency of the payment page
                srand(time()); // initialize random generator for x_fp_sequence
                $x_fp_sequence = rand(1000, 100000) + 123456;
                $x_fp_timestamp = time(); // needs to be in UTC. Make sure webserver produces UTC
  
                // The values that contribute to x_fp_hash 
                $hmac_data = $x_login . "^" . $x_fp_sequence . "^" . $x_fp_timestamp . "^" . $x_amount . "^" . $x_currency_code;
                $x_fp_hash = hash_hmac('MD5', $hmac_data, $transaction_key);
  
                echo ('&lt;label&gt;x_login&lt;/label&gt;&lt;input name="x_login"  type="hidden" value="' . $x_login . '"&gt;' );
                echo ('&lt;label&gt;x_amount&lt;/label&gt;&lt;input name="x_amount"  type="hidden" value="' . $x_amount . '"&gt;' );
                echo ('&lt;label&gt;x_fp_sequence&lt;/label&gt;&lt;input name="x_fp_sequence"  type="hidden" value="' . $x_fp_sequence . '"&gt;' );
                echo ('&lt;label&gt;x_fp_timestamp&lt;/label&gt;&lt;input name="x_fp_timestamp"  type="hidden" value="' . $x_fp_timestamp . '"&gt;' );
                echo ('&lt;label&gt;x_fp_hash&lt;/label&gt;&lt;input name="x_fp_hash"  type="hidden" value="' . $x_fp_hash . '" size="50"&gt;' );
                echo ('&lt;label&gt;x_currency_code&lt;/label&gt;&lt;input name="x_currency_code"  type="hidden" value="' . $x_currency_code . '"&gt;');
          ?&gt;
  
                &lt;input type="hidden" name="x_show_form" value="PAYMENT_FORM"/&gt;
                &lt;input type="hidden" name="x_test_request" value="FALSE"/&gt;
                Enter Payment Amount:&lt;br&gt;
                &lt;input type="text" name="x_amount"/&gt;
                &lt;input type="submit" value="Pay with Payment Pages"/&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>In other words, can I collect the x amount, generate the hash and then post it to the third party with just one click of the submit button?  How can I accomplish this?</p>