Hiding a form and submitting it behind the scenes

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
perdi202
Forum Newbie
Posts: 2
Joined: Thu Jul 08, 2004 7:53 pm

Hiding a form and submitting it behind the scenes

Post by perdi202 »

Hi All,

I have been trying to make a form, call another form and submit itself, for making calls to payment gateways like paypal for example, and am drawing a blank so far.

What I do now
Usually, you have a payment form and a submit button, and the submit button will do the form action, which is calling the payment gateway. For example.

Code: Select all

<form action='https://www.paypal.com/cgi-bin/webscr' method='post' name='frm_pay'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='someone2@yahoo.com'>
<input type='hidden' name='item_name' value='Test Item'>
<input type='hidden' name='item_number' value='ItemNumber'>
<input type='text' name='amount' value='100.00'>
<input type='text' name='no_note' value='1'>
<input type='' name='currency_code' value='USD'>
</form>
Anyone who does a view html source will see all this information, and know that the payment is being made to paypal to someone2 etc etc.

What I want to do

Code: Select all

<form action='http://mysite/form2.php' method='post' name='frm_pay'>
<input type='text' name='amount' value='100.00'>
<input type='text' name='no_note' value='1'>
</form>
Form2 then builds the rest of the variables behind the scenes, and submits itself to paypal, taking the user directly to the paypal page. A user would never see hidden variables by doing view html source...

Anyone implemented such a scheme successfully?

Thanx in advance
Perdi
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

perdi202
Forum Newbie
Posts: 2
Joined: Thu Jul 08, 2004 7:53 pm

Post by perdi202 »

Tried it out and it is definitely a solution, but I am looking for a more generic answer. Can I do this.

I have:
Script1.php which has form1 which calls script2.php on submit.
Script2.php which has form2 which calls script3.php on submit.

Action reqd:
1. User presses submit on form1 in script1.
2. Script2 does some processing and submits form2.php without ANY user intervention and script3 is loaded.

Essentially, I am looking for self-submitting form code.

Thanx
Perdi
Post Reply