title: PHP and Paypal. When click submit, save data to database and redirect to paypal
body: <p>I have the form below, and I wondered if there's a way, when the user click the submit button, save the data, like $shipping_price, $invoice_id to the database and redirect the user to paypal to pay.</p>
  
  <pre><code>    &lt;form action="https://secure.paypal.com/uk/cgi-bin/webscr" method="post" name="paypal" id="paypal"&gt;
      &lt;!-- Prepopulate the PayPal checkout page with customer details, --&gt;
      &lt;input type="hidden" name="first_name" value="&lt;?php echo Firstname?&gt;"&gt;
      &lt;input type="hidden" name="last_name" value="&lt;?php echo Lastname?&gt;"&gt;
      &lt;input type="hidden" name="email" value="&lt;?php echo Email?&gt;"&gt;
      &lt;input type="hidden" name="address1" value="&lt;?php echo Address?&gt;"&gt;
      &lt;input type="hidden" name="address2" value="&lt;?php echo Address2?&gt;"&gt;
      &lt;input type="hidden" name="city" value="&lt;?php echo City?&gt;"&gt;
      &lt;input type="hidden" name="zip" value="&lt;?php echo Postcode?&gt;"&gt;
      &lt;input type="hidden" name="day_phone_a" value=""&gt;
      &lt;input type="hidden" name="day_phone_b" value="&lt;?php echo Mobile?&gt;"&gt;
  
      &lt;!-- We don't need to use _ext-enter anymore to prepopulate pages --&gt;
      &lt;!-- cmd = _xclick will automatically pre populate pages --&gt;
      &lt;!-- More information: https://www.x.com/docs/DOC-1332 --&gt;
      &lt;input type="hidden" name="cmd" value="_xclick" /&gt;
      &lt;input type="hidden" name="business" value="paypal@email.com" /&gt;
      &lt;input type="hidden" name="cbt" value="Return to Your Business Name" /&gt;
      &lt;input type="hidden" name="currency_code" value="GBP" /&gt;
  
      &lt;!-- Allow the customer to enter the desired quantity --&gt;
      &lt;input type="hidden" name="quantity" value="1" /&gt;
      &lt;input type="hidden" name="item_name" value="Name of Item" /&gt;
  
      &lt;!-- Custom value you want to send and process back in the IPN --&gt;
      &lt;input type="hidden" name="custom" value="&lt;?php echo session_id().?&gt;" /&gt;
  
      &lt;input type="hidden" name="shipping" value="&lt;?php echo $shipping_price; ?&gt;" /&gt;
      &lt;input type="hidden" name="invoice" value="&lt;?php echo $invoice_id ?&gt;" /&gt;
      &lt;input type="hidden" name="amount" value="&lt;?php echo $total_order_price; ?&gt;" /&gt;
      &lt;input type="hidden" name="return" value="http://&lt;?php echo $_SERVER['SERVER_NAME']?&gt;/shop/paypal/thankyou"/&gt;
      &lt;input type="hidden" name="cancel_return" value="http://&lt;?php echo $_SERVER['SERVER_NAME']?&gt;/shop/paypal/cancelled" /&gt;
  
      &lt;!-- Where to send the PayPal IPN to. --&gt;
      &lt;input type="hidden" name="notify_url" value="http://&lt;?php echo $_SERVER['SERVER_NAME']?&gt;/shop/paypal/process" /&gt;
  &lt;/form&gt;
  </code></pre>