title: Insert into MySQL when POST form to Paypal
body: <p>I've been struggling with this for hours and can't wrap my head around where/how to call a php function to insert order details into MySQL upon user clicking the Buy button (doing so at this point allows me to track orders that go to Paypal and then are abandoned).</p>
  
  <p>I thought to put it in the <code>&lt;form action=&gt;</code> tag, (for example, <code>&lt;form action='addToMySQL.php' method='post'&gt;</code>) but that's where the Paypal url goes, yes? Function must be run server side, so can't use js... So... how to do this?</p>
  
  <p>cURL has been suggested, and I've seen it recommended before, but would the user still be redirected to Paypal's payment page and then returned back to my site? Can anyone suggest a relevant web tutorial?</p>
  
  <p>I'm new to web programming so details would be appreciated.</p>
  
  <p>Function that creates the form to be sent to PayPal is:</p>
  
  <pre><code>function create_paypal_checkout {
  return "
  &lt;form action='".PAYPAL_URL."' method='post'&gt;
      &lt;input type='hidden' name = 'business' value='".PAYPAL_ID."' /&gt;
      &lt;input type='hidden' name = 'cmd' value='_cart' /&gt;
      &lt;input type='hidden' name = 'upload' value='1' /&gt;
      &lt;input type='hidden' name = 'currency_code' value='USD' /&gt;
      &lt;input type='hidden' name = 'lc' value='US' /&gt;
      &lt;input type='hidden' name='rm' value='2' /&gt;
      &lt;input type='hidden' name='cancel_return' value='http://www.mydomain.com/'&gt;
      &lt;input type='hidden' name='notify_url' value='http://www.mydomain.com/ipn-listener.php'&gt;
      &lt;input type='hidden' name='return' value='http://www.mydomain.com/thankyou.php?custIP=".$custip."' /&gt;
  
      " . render_shopping_cart($shopping_cart) . "
  
  &lt;table class='formBuyButton'&gt;
  &lt;tr id='sc_total'&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td id='ppbutt'&gt;
          &lt;input type='image' name='submit' src='https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_buynowCC_LG.gif' border='0' alt='PayPal - Buy Now' /&gt;
      &lt;/td&gt;
  &lt;/form&gt;&lt;/tr&gt;&lt;/table&gt;" ;
  }
  </code></pre>