Form submit OnLoad?

What is the best method to have a classic asp form submit on page load? I am capturing user info from a form on the 1st page. On this second page I am sending an email with the captured form data; then I need to submit this PayPal form so the user is sent to the PayPal payment page. I don't want the user to have to click the PayPal button on the second page after submitting the initial user info form on the first page.

Thanks
Andrew
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="frmPayPal">

Open in new window

AhelblingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sammySeltzerCommented:
If it is the user who is submitting the form, then redirect the user to paypal after email is sent using response.redirect

Alternatively, if you have 2 files, one to collect information and the other to process, then on the process page, again, after email is sent, do this:

<head>
      <title>Please wait...</title>
      <META HTTP-EQUIV="refresh" content="1;url=https://www.paypal.com/cgi-bin/webscr" method="post" name="frmPayPal">
</head>

And that should automatically take the user to pay pay


0
AhelblingAuthor Commented:
Ok thanks, but in the 2nd example wont the email fire off twice if the page refreshes?
0
AhelblingAuthor Commented:
nevermind - I see that what it is doing now
0
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

sammySeltzerCommented:
sorry, a slight mistake on my post.

There should be no method=post

Should be:

<head>
      <title>Please wait...</title>
      <META HTTP-EQUIV="refresh" content="1;url=https://www.paypal.com/cgi-bin/webscr">
</head>


sorry about that.
0
sammySeltzerCommented:
Also, you can either make this:

content="1;

become

content="1; if you don't want the user to know she/he is being redirected

OR increase it from 1 to perhaps 2 or 3 seconds if you want the user to know s/he is being redirected.
0
AhelblingAuthor Commented:
ok, but there is a bunch of PayPal form data that must be passed to the PayPal url also...


example:


<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="frmPayPal" onsubmit="return checkform()" style=" padding-left:1.5em\9;">
	<!-- Identify your business so that you can collect the payments. -->
	<input name="business" type="hidden" value="ahelbling@danforthcenter.org" />
	<!-- Specify a Donate button. -->
	<input name="cmd" type="hidden" value="_donations" />
	<!-- Specify details about the contribution -->
	<input name="item_name" type="hidden" value="Danforth Center Donations" />
	<input name="item_number" type="hidden" value="The Danforth Society &amp; Friends of Plant Science" />
	<input name="currency_code" type="hidden" value="USD" />

	<input name="return" type="hidden" value="http://www.danforthcenter.org/" />

Open in new window

0
sammySeltzerCommented:
In that case, create a hidden form with action pointed to paypal url.

Something like:

<input type="hidden" name="return" value="https://www.paypal.com/cgi-bin/webscr">      <input name="business" type="hidden" value="ahelbling@danforthcenter.org" />
      <!-- Specify a Donate button. -->
      <input name="cmd" type="hidden" value="_donations" />
      <!-- Specify details about the contribution -->
      <input name="item_name" type="hidden" value="Danforth Center Donations" />
      <input name="item_number" type="hidden" value="The Danforth Society &amp; Friends of Plant Science" />
      <input name="currency_code" type="hidden" value="USD" />

      <input name="return" type="hidden" value="http://www.danforthcenter.org/" />


You should have your regular <form action="yourprocess.asp"> it will redirect user to paypal page.

Give that a try
0
AhelblingAuthor Commented:
Ok, I think I am still missing something...

Page1.asp collects user form data and passes it to Page2.asp.
Page2.asp sends an email containing the collected form data,  then needs to submit the PayPal form with hidden values in it.

How exactly are we to submit this "hidden" form after the email is sent?

Sorry for the confusion
0
sammySeltzerCommented:
That key thing there is return.

<input type="hidden" name="return" value="https://www.paypal.com/cgi-bin/webscr">

Open in new window

The URL that you redirect users to after they complete this form. All your hidden form values will passed along.
0
AhelblingAuthor Commented:
ok but there is nothing the user is filling out on page2.asp - it is to send the email then automatically redirect to PayPay url with the hidden form data. The user never actually clicks submit on page2.asp

sorry i am not gettin it
0
AhelblingAuthor Commented:
is this to be on page1.asp or page2.asp?


<input type="hidden" name="return" value="https://www.paypal.com/cgi-bin/webscr">

0
sammySeltzerCommented:
page1.asp.

One thing I forgot to mention is that on your paypal page where you set up your acctount, you need to enable auto return.

This way, as soon as your page is submitted, users are automatically redirected to that page.

It is also worthy to not that on your paypal account page, you use the get() method.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AhelblingAuthor Commented:
Ok thanks, I will play around with it and see how it goes today.
0
Wayne BarronAuthor, Web DeveloperCommented:
Several years ago I designed a site that I thought would be something special.
Though I LOVE the way i designed it, and everyonce in a while I will launch it to see what it looks like today, BUT, I HATE the coding practice that I used back then.
Was all DW code from someone elses projects.
Now today, I write everything from scratch..
How times have changed.

Anyway, this question you asked to brought that memory back into my thoughts.
And well, I created a Register page, which consisted of about 20 pages.. (Yea I know, 20 pages to register on a site)
But all the pages used this:

<body onLoad="document.fHtmlEditor.submit()">
<form name="fHtmlEditor" method="post" action="http://www.enterview.org">
<input name="sDate" type="hidden" value="Value #1" />
<input name="sTime" type="hidden" value="Value #2" />
<input name="sImage" type="hidden" value="xgk0zm" />
</form>
</body>

This code works really well.
I have not used it in years, but just tested this out to make sure that it fires on page load and it does.

Good Luck
Carrzkiss
0
AhelblingAuthor Commented:
@ carrzkiss

Thanks, I will give that a shot as well...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.