php - Insert into MySQL when POST form to Paypal -
i've been struggling hours , can't wrap head around where/how call php function insert order details mysql upon user clicking buy button (doing @ point allows me track orders go paypal , abandoned).
i thought put in <form action=> tag, (for example, <form action='addtomysql.php' method='post'>) that's paypal url goes, yes? function must run server side, can't use js... so... how this?
curl has been suggested, , i've seen recommended before, user still redirected paypal's payment page , returned site? can suggest relevant web tutorial?
i'm new web programming details appreciated.
function creates form sent paypal is:
function create_paypal_checkout { return " <form action='".paypal_url."' method='post'> <input type='hidden' name = 'business' value='".paypal_id."' /> <input type='hidden' name = 'cmd' value='_cart' /> <input type='hidden' name = 'upload' value='1' /> <input type='hidden' name = 'currency_code' value='usd' /> <input type='hidden' name = 'lc' value='us' /> <input type='hidden' name='rm' value='2' /> <input type='hidden' name='cancel_return' value='http://www.mydomain.com/'> <input type='hidden' name='notify_url' value='http://www.mydomain.com/ipn-listener.php'> <input type='hidden' name='return' value='http://www.mydomain.com/thankyou.php?custip=".$custip."' /> " . render_shopping_cart($shopping_cart) . " <table class='formbuybutton'> <tr id='sc_total'> <td> </td> <td> </td> <td id='ppbutt'> <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' /> </td> </form></tr></table>" ; }
i had same problem , solved using ajax. call php script using ajax before submitting form paypal. here, i'm using post function jquery, since easier. need have jquery somewhere , point it. when user submit form, mycall() first called, , if returns true, form submitted paypal.
<script type="text/javascript" src="jquery-1.4.2.min.js"></script> <script type="text/javascript"> function mycall() { $.post('addtomysql.php', {...}); // replace ... arguments return true; } </script> <form action='".paypal_url."' method='post' onsubmit='return mycall();'>
Comments
Post a Comment