how to submit a form threw php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

how to submit a form threw php?

Post 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:
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

by using a simple if $_POST['option'] == 'whatever'{ //do something }
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

dont queit understand. i need to redirect to that paypal page without the user clicking on the button.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post by psychotomus »

how can I make javascrtipt click on the botton?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

document.forms&#1111;0].elements&#1111;'submit'].click()
or similar, I believe.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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...
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
.....
Post Reply