Page 1 of 1

how to submit a form threw php?

Posted: Wed Mar 09, 2005 11:07 pm
by psychotomus
I need to submit this form. How can I submit it with php?

The script is choosing between 2 options. if the option is a paid subscription. its updates sql tables then should redirect to this form. How do I post to that form?

Code: Select all

<form action=&quote;https://www.paypal.com/cgi-bin/webscr&quote; method=&quote;post&quote;>
<input type=&quote;hidden&quote; name=&quote;cmd&quote; value=&quote;_xclick&quote;>
<input type=&quote;hidden&quote; name=&quote;business&quote; value=&quote;ads@trugroovez.com&quote;>
<input type=&quote;hidden&quote; name=&quote;item_name&quote; value=&quote;Premier  Site Submission&quote;>
<input type=&quote;hidden&quote; name=&quote;item_number&quote; value=&quote;002&quote;>
<input type=&quote;hidden&quote; name=&quote;amount&quote; value=&quote;12.95&quote;>
<input type=&quote;hidden&quote; name=&quote;no_note&quote; value=&quote;1&quote;>
<input type=&quote;hidden&quote; name=&quote;currency_code&quote; value=&quote;GBP&quote;>
<input type=&quote;image&quote; src=&quote;http://www.vfunk.com/images/pay_pal_button.gif&quote; name=&quote;submit&quote; alt=&quote;Make payments with PayPal - it's fast, free and secure!&quote;>
</form>

feyd | :roll:

Posted: Wed Mar 09, 2005 11:09 pm
by infolock
by using a simple if $_POST['option'] == 'whatever'{ //do something }

Posted: Wed Mar 09, 2005 11:19 pm
by psychotomus
dont queit understand. i need to redirect to that paypal page without the user clicking on the button.

Posted: Wed Mar 09, 2005 11:27 pm
by feyd
ghetto way: have Javascript "click" the button on the resultant page.

different way: use curl to submit the form on behalf of the user, manipulating the resultant page.. although that would likely not work well because it's going to a secure page..

Posted: Wed Mar 09, 2005 11:29 pm
by psychotomus
how can I make javascrtipt click on the botton?

Posted: Wed Mar 09, 2005 11:33 pm
by feyd

Code: Select all

document.forms&#1111;0].elements&#1111;'submit'].click()
or similar, I believe.

Posted: Wed Mar 09, 2005 11:41 pm
by psychotomus

Code: Select all

<form action=&quote;https://www.paypal.com/cgi-bin/webscr&quote; method=&quote;post&quote;>
<input type=&quote;hidden&quote; name=&quote;cmd&quote; value=&quote;_xclick&quote;>
<input type=&quote;hidden&quote; name=&quote;business&quote; value=&quote;ads@trugroovez.com&quote;>
<input type=&quote;hidden&quote; name=&quote;item_name&quote; value=&quote;Premier  Site Submission&quote;>
<input type=&quote;hidden&quote; name=&quote;item_number&quote; value=&quote;002&quote;>
<input type=&quote;hidden&quote; name=&quote;amount&quote; value=&quote;12.95&quote;>
<input type=&quote;hidden&quote; name=&quote;no_note&quote; value=&quote;1&quote;>
<input type=&quote;hidden&quote; name=&quote;currency_code&quote; value=&quote;GBP&quote;>
<input type=&quote;image&quote; src=&quote;http://www.vfunk.com/images/pay_pal_button.gif&quote; name=&quote;submit&quote; alt=&quote;Make payments with PayPal - it's fast, free and secure!&quote;>
</form>

<script type=&quote;javascript&quote;>
document.forms&#1111;0].elements&#1111;'submit'].click()
</script>
not working. any suggestions?

Posted: Thu Mar 10, 2005 12:11 am
by infolock
do you have any other forms besides that one on the same page? if so, then you are gonna need to supply the form in question with a NAME and then call the click via it's name in the document javascript call...

Posted: Thu Mar 10, 2005 1:18 am
by psychotomus
cant get it to work

Code: Select all

<form action=&quote;https://www.paypal.com/cgi-bin/webscr&quote; name=&quote;tester&quote; method=&quote;post&quote;>
		<input type=&quote;hidden&quote; name=&quote;cmd&quote; value=&quote;_xclick&quote;>
		<input type=&quote;hidden&quote; name=&quote;business&quote; value=&quote;ads@trugroovez.com&quote;>
		<input type=&quote;hidden&quote; name=&quote;item_name&quote; value=&quote;Premier  Site Submission&quote;>
		<input type=&quote;hidden&quote; name=&quote;item_number&quote; value=&quote;002&quote;>
		<input type=&quote;hidden&quote; name=&quote;amount&quote; value=&quote;12.95&quote;>
		<input type=&quote;hidden&quote; name=&quote;no_note&quote; value=&quote;1&quote;>
		<input type=&quote;hidden&quote; name=&quote;currency_code&quote; value=&quote;GBP&quote;>
		<input type=&quote;hidden&quote; src=&quote;http://www.vfunk.com/images/pay_pal_button.gif&quote; name=&quote;submit&quote; alt=&quote;Make payments with PayPal - its fast, free and secure!&quote;>
		</form>
		<SCRIPT LANGUAGE=&quote;text/JavaScript&quote;>
			document.tester.submit();
		</SCRIPT>
isnt this correct or am I overlooking something simple?

Posted: Thu Mar 10, 2005 7:30 am
by Chris Corbyn

Code: Select all

<form id=&quote;paypalForm&quote; action=&quote;https://www.paypal.com/cgi-bin/webscr&quote; name=&quote;tester&quote; method=&quote;post&quote;>
		<input type=&quote;hidden&quote; name=&quote;cmd&quote; value=&quote;_xclick&quote;>
		<input type=&quote;hidden&quote; name=&quote;business&quote; value=&quote;ads@trugroovez.com&quote;>
		<input type=&quote;hidden&quote; name=&quote;item_name&quote; value=&quote;Premier  Site Submission&quote;>
		<input type=&quote;hidden&quote; name=&quote;item_number&quote; value=&quote;002&quote;>
		<input type=&quote;hidden&quote; name=&quote;amount&quote; value=&quote;12.95&quote;>
		<input type=&quote;hidden&quote; name=&quote;no_note&quote; value=&quote;1&quote;>
		<input type=&quote;hidden&quote; name=&quote;currency_code&quote; value=&quote;GBP&quote;>
		<input type=&quote;hidden&quote; src=&quote;http://www.vfunk.com/images/pay_pal_button.gif&quote; name=&quote;submit&quote; alt=&quote;Make payments with PayPal - its fast, free and secure!&quote;>
		</form>
		<SCRIPT LANGUAGE=&quote;text/JavaScript&quote;>
			document.getElementById('paypalForm').submit();
		</SCRIPT>

Posted: Thu Mar 10, 2005 8:37 am
by feyd
d11's will have an error.. as there is an element named 'submit' that will be called before the submit method can be found and called. That's the dilemma. If you change the name of the image button, then it has the potential to work.

Posted: Thu Mar 10, 2005 8:40 am
by Chris Corbyn
feyd wrote:d11's will have an error.. as there is an element named 'submit' that will be called before the submit method can be found and called. That's the dilemma. If you change the name of the image button, then it has the potential to work.
My bad... I overlooked that. I just copied/pasted and modified the right bits but missed the submit name. Take it out. I was just trying to get away from the ambiguity as to whether it was forms[0] or not :P

Posted: Thu Mar 10, 2005 11:06 am
by PrObLeM

Posted: Thu Mar 10, 2005 12:13 pm
by John Cartwright
feyd wrote: different way: use curl to submit the form on behalf of the user, manipulating the resultant page.. although that would likely not work well because it's going to a secure page..
PrObLeM wrote:use cURL

http://www.php.net/curl
.....