Forum Moderators: coopster

Message Too Old, No Replies

PHP Email Form/PayPal submit - part 2

Got the form working but? on the passing function

         

TomJones

4:22 pm on Apr 16, 2003 (gmt 0)

10+ Year Member



Got the email working easily but, I'm? at how to merge that with the Paypal button (form) to perform both actions. PayPal's button is a form calling the button image, etc., from PayPal. How do I merge the two forms so that the PP button ;0 performs the SUBMIT on the email form and, then jumps to the PP site? Thanks again and again and again...... PHP is at least starting to sink through the hard outter shell.

jatar_k

4:27 pm on Apr 16, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the paypal form is just a bunch of hidden fields if I am not mistaken with a form action that goes to paypal.

Take the url out of the form action and add it into another hidden field. Then dump all of those hidden fields into the other form. When you do your redirect to paypal you will have to build the url from the hidden fields and then redirect the visitor.

Just make sure that you don't have any repeated field names or it could make a bit of a mess.

TomJones

2:28 am on Apr 17, 2003 (gmt 0)

10+ Year Member



Makes sense. I couldn't figure the order of things. I haven't fooled with redirects yet but, I have a good idea of what they do and a book so, I'll give it a try. One question still looming, am I assigning the sendmail SUBMIT to the PayPal button? The whole deal is trying to use the PayPal button as the 2in1. And then, it stops making sense. I'm gonna start digging around and, see what happens. Hope I don't end up buy $10,000 worth of my own junk from PayPal ;)

rainborick

3:38 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't use PHP, so please excuse me if this is can't be done with that language, but it seems to me that you have only two options if you want to intercept a PayPal payment form, do some local sendmail magic, and then send the user on his merry way to give you his money.

The first method is simple, but it depends on PayPal's cgi interface being written in a generic manner to accept bot POST and GET type form submissions. (Not an outrageous assumption, but you won't know until you try). On the HTML page, you set the <form>'s ACTION element to point to your php code. The php code performs said local magic, and then instead of emitting the HTTP "Content-Type: text/html" header followed by some <HTML>, you instead emit a "Location:" header with a URL pointing to the PayPal cgi code, including a query string consisting of all of the field name and value pairs, as in:

Location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&busines=YourBizName&item_name=YourItem&item_number=01&amount=.01\n\n

(there are more parameters required, but you get the idea).

If PayPal won't handle this access method, the only alternative I see is, again perform your magic and then have your php script emit an <HTML> page containing only an invisible <FORM> whose ACTION is pointed to PayPal as normal, and populated with the appropriate <item type="hidden" value="whatever"> elements, and then set the BODY tag to <body onload="document.forms[0].submit();">. Its clumsy, very brute-force-ish, and relies on the user having JavaScript enabled, but it should get the job done.

[edited by: jatar_k at 3:46 pm (utc) on April 17, 2003]
[edit reason] sidescroll [/edit]

jatar_k

3:49 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



am I assigning the sendmail SUBMIT to the PayPal button

I think yes is the answer here. I would say it more like using the paypal button to submit the form who's action targets your 2 in 1 script.

and Welocme to WebmasterWorld rainborick :)

TomJones

12:10 am on Apr 24, 2003 (gmt 0)

10+ Year Member



Just wanted to post my results and thanks.

I was able to just redirect using the http given by Paypal for email submission. Since I was sending everything through Sendmail, it was no bother that the hidden fields weren't used in the Paypal submission. I could even specify the redirect back from Paypal in the http. Can't believe I spent two days on figuring that one out.

Thanks again for the suggestions!