PDA

View Full Version : moving data from asp form to .jsp URL


jim_wintner
09-24-2008, 10:57 PM
Hello and thanks in advance for any help.

I would like to pass form information that comes from a standard asp form into a URL string(example follows):

"http://ui.constantcontact.com/roving/wdk/API_AddSiteVisitor.jsp?loginName=benefitevents&loginPassword=xxxxxxxxx&ea=foo@bar.com&ic=test&first_name=Joe&last_name=smith"

I would then like to pass that string forward to its final destination. Login and password are fixed in advance. Email, first/last name come from form.

Some more info.

Form data is collected on "register.asp" and then passed to "register1.asp" using form method="post" action="register1.asp".

On register1.asp the form info is processed and delivered to the SQL database.

I am only a beginner with the code (it was done by a programmer who is mostly absent when needed now).

So, I need to know as much of the following as you can help with (in descending priority):

1. How to pass the .jsp string forward assuming the proper variables have been passed in the asp code. (I'm guessing this might be some kind of onload event in register1.asp). Successfully uploading the string returns a page with a "0" in one corner. I would not want that page seen. I have done this just by writing into browser address bar the string (and also using simple submit in a form with the URL as the action).

2. Where should this command live, in register.asp or register1.asp?

3. How to correctly insert the variables in the URL string from form (correct syntax using asp).

As may be obvious this is for one registrant at a time. The object is deliver the registration information to my SQL database and, at the same time, pass some info to a Constant Contact list. This allows me to integrate Constant Contact into my services to clients seamlessly.

Thank you, hope this was not too much info!

Jim

Spudhead
09-25-2008, 02:01 PM
Just so I'm clear...

You collect data in a form on register.asp. It posts data to register1.asp, which does some stuff with it. You then want to pass this data to another site via a HTTP GET (ie: you send a load of stuff to a page in a querystring)

If that's the case, sounds like you need XMLHTTP:

<%
DataToSend = "loginName=benefitevents&loginPassword=xxxxxxxxx&ea=foo@bar.com&ic=test&first_ name=Joe&last_name=smith"
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET","http://ui.constantcontact.com/roving/wdk/API_AddSiteVisitor.jsp",false
xmlhttp.send DataToSend
Response.Write xmlhttp.responsetext
Set xmlhttp = nothing
%>

Put that on your register1.asp page and it'll let you chuck all your data at this constantcontact page, without even leaving your page.

jim_wintner
09-25-2008, 07:00 PM
Dear Spudhead,

Thank you for your response. Can you also advise on the proper way to place the current email address (ea) and first and last name into the string being passed to Constant Contact?

These variables are all found on register1.asp. If you like I can send you a copy of the register1.asp (minus the sql upload passwords).

Jim

Spudhead
09-26-2008, 02:07 PM
Well... say you've got a field on your form, called "email":

<input type="text" name="email">

You'd be getting the value of that field on your register1.asp page by using:

strEmail = request.form("email")

To then use that variable in your data that you send, you build a string like so:

DataToSend = "loginName=benefitevents&loginPassword=xxxxxxxxx&ea=" & strEmail & "&ic=test&first_ name=Joe&last_name=smith"

You just repeat that for all your other form fields.

Make sense?

jim_wintner
09-26-2008, 09:05 PM
Spudhead,

Thank you, I was confused as to where the double quotes would stop and start.

I will report back after trying.

Much thanks,
Jim

jim_wintner
09-26-2008, 09:26 PM
Spudhead,

If I construct the string in question as follows:

DataToSend = "loginName=benefitevents&loginPassword=xxxxxxxx&ea=" & email & "&ic=test&first_ name=" & FirstName & " & last_name=" & LastName & ""

I'm not sure I have the correct termination after LastName.

Thank you!

Jim

brazenskies
09-27-2008, 06:44 PM
try...

DataToSend = "loginName=benefitevents&loginPassword=xxxxxxxx&ea=" & email & "&ic=test&first_ name=" & FirstName & "&last_name=" & LastName

If in doubt it's always good to print it out to the screen to see how it looks...

response.write(DataToSend)

jim_wintner
09-27-2008, 10:45 PM
Thank you (both), I think I understand now.

Jim

jim_wintner
10-09-2008, 07:10 PM
This is the version of the code that works. The main change from the earliest advice was to move DataToSend into the URL string, from "xmlhttp.send", as below. I commented out Response.Write for real time. Helpful for testing.

Thanks to all,
Jim

DataToSend = "loginName=benefitevents&loginPassword=xxxxxxxxx&ea=" & email & "&ic=test&first_name=" & FirstName & " &last_name=" & LastName
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET","http://ui.constantcontact.com/roving/wdk/API_AddSiteVisitor.jsp?" & DataToSend,false
xmlhttp.send
Response.Write xmlhttp.responsetext
Set xmlhttp = nothing