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?
 
sammySeltzerConnect With a Mentor Commented:
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
 
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
AhelblingAuthor Commented:
nevermind - I see that what it is doing now
0
 
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
 
AhelblingAuthor Commented:
Ok thanks, I will play around with it and see how it goes today.
0
 
Wayne BarronConnect With a Mentor Author, 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.