Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 2nd, 2008, 09:37 AM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page redirect help

I have a page that receives data through a "post" but I also need to forward that information to another server. For example:

  Customer makes a payment and that info is processed and then the data posted to a receipt, but we also need that data to post to an external database. (Our database is hosted on a separate server remotely.)

Any ideas? I'm using .asp pages (no .net).

Thanks in advance.
  #2 (permalink)  
Old July 2nd, 2008, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

*HOW* do you do (need to do) the post to the DB server???

Do you mean you need to call a WEB PAGE on the DB server? Or a Web Service? Or what?

You could certainly make a web request to the other server:

<%
Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
http.Open "GET", "http://www.otherSiteName.com/hereIsData.asp?user=13&amount=17.73"
http.Send

If http.Status <> 200 Then
    ... error ...
End If

... now output the info back to the web page on the client ...
%>

And, yes, you can POST data instead of GET.

But we need details that you aren't giving.
  #3 (permalink)  
Old July 9th, 2008, 08:58 AM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let me try and clarify. I have a shopping cart. My visitor adds all the things that they need from Client store #1. I gather the info through a forms page, which posts all the pertinent information to my database (hosted by me), which then displays a receipt page. What I also need to do is send the information to my Client's store database (that they host). I do not want my visitor redirected to my Client's pages only the transaction information.

Ex. Janie visits my webpage (I have lots of clients who host stores with me) and chooses items from a single store. The data posts to my database and then her payment is processed and she sees a receipt displayed. BUT my client needs to know what's been purchased from his store (so I'd like to send a datastream to him...possibly an XML or AJAX string) but I don't want my visitor redirected to his site.

Hope that makes sense. Thanks for your help!
  #4 (permalink)  
Old July 9th, 2008, 02:02 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

So I gave you the right answer.

After validating the order, etc., etc., and adding it to your local DB, just use MSXML2.ServerXMLHTTP to invoke a web page on your client's server. That web page can be written in any language. All you are looking for is the ability to send it info and for it to send you back an "I've got it" response.

I would strongly advocate that you encrypt the info going to the client's server, including a password known ONLY to you and that one web page on client.

Note that ASP/VBScript will require that you do this SYNCHRONOUSLY. That is, your code should wait for the "OKAY" (or whatever) response from the client before then proceeding to send the HTML back to the browser. For this reason, make sure the client computer's web page *can* respond quickly, even if it then needs to do additonal processing to store the data you just sent.
  #5 (permalink)  
Old July 14th, 2008, 03:46 PM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure how I'd go about that. Do you happen to know of a good resource on MSXML2.ServerXMLHTTP commands and information?

Thanks. I'm a very straightforward .asp programmer.
  #6 (permalink)  
Old July 14th, 2008, 04:00 PM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When I said "straightforward" I meant it's gotta be uncomplicated for me to "get it".

Here's my big problem, I'm getting a bunch of variables from a shopping cart to my page "gotasale.asp". There is an intermediate page called "inbetween.asp", which writes all the transaction data to my internal database (MS SQL) through a form post and then goes to my page "customerreceipt.asp". Somewhere in all those step, I need to take the transaction data and send it to my client's website at the address "https://www.someclientsname.com/heresasale.asp".

What's the simplest/best way to do that without my shopping cart customer getting redirected to the someclientsname website? (I want my customer's last page to be "customerreceipt.asp."
  #7 (permalink)  
Old July 14th, 2008, 06:45 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, you complicated things a good deal there when you added in the httpS:

If it weren't for that, the answer I gave you first would be correct.

<%
Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
http.Open "POST", "https://www.someclientsname.com/heresasale.asp"
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send Request.Form ' if you want to send *ALL* form data to the "heresasale.asp" page

If http.Status <> 200 Then
    ... error ...
End If

... now output the info back to the web page on the client ...
%>

But to use "https://" you have to supply the other server with a valid certificate of your own.

Look here:
http://www.google.com/search?hl=en&q...tp+certificate

Never done this myself, so you're on your own.

I might note that you do *NOT* have to send *ALL* the Request.Form data to the other server. You can, instead, build up a POST string. Which looks essentially identical to an encode QueryString but with no leading question mark. That is, you could do something like:

http.Send "name=" & Escape( Request("name") ) & "&amount=" & Escape( Request("amount") )

[ESCAPE( ) is the near-equivalent of Server.URLEncode. If one doesn't work, use the other.]
  #8 (permalink)  
Old August 11th, 2008, 11:01 AM
Authorized User
Points: 292, Level: 5
Points: 292, Level: 5 Points: 292, Level: 5 Points: 292, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's taken me a while to get this going. But I just wanted to thank you soooooo much! It worked like a charm! I cannot say thank you enough.

May your day be bright and wonderful!
:D


Similar Threads
Thread Thread Starter Forum Replies Last Post
redirect to page other than default page sarah lee ASP.NET 1.0 and 1.1 Basics 3 December 15th, 2006 05:45 PM
Redirect to new page without closing current page peter2004 ASP.NET 2.0 Basics 5 June 5th, 2006 08:49 PM
Redirect to next page qazi_nomi Javascript How-To 1 September 1st, 2004 02:07 AM
Redirect page Warbird Classic ASP Basics 4 June 20th, 2003 07:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.