• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Form Redirect

New Here ,
Jun 10, 2006 Jun 10, 2006

Copy link to clipboard

Copied

Hi, I'm trying to redirect a form post from one http sever to another.
I have two coldfusion pickupdepot scripts that accept IPN posts from paypal. Sometimes paypal posts to the wrong one, so here is what i need to do.
I want pickupdepot1 to redirect certain posts to the other pickupdot2. I know its not as simple as a redirect.
I want pickupdepot1 to see the incoming post from paypal, then based on my query, Just forward the post to another url. can this be done?

Thanks

Tony Paolillo
TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 10, 2006 Jun 10, 2006

Copy link to clipboard

Copied

You can do this with a cfhttp and GetHttpRequestData() although this could get messy quickly.

Perhaps a more productive tack is to arrange your servers in a true clustered manner.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2006 Jun 11, 2006

Copy link to clipboard

Copied

pickupdepot1.cfm
===============
<!--- see the incoming post from paypal, then based on my query, Just forward the post --->
<cfscript>
getPageContext().forward("pickupdepot2.cfm");
</cfscript>




corrected: </cfscript>



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 11, 2006 Jun 11, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: BKBK
pickupdepot1.cfm
===============
<!--- see the incoming post from paypal, then based on my query, Just forward the post --->
<cfscript>
getPageContext().forward("pickupdepot2.cfm");
<cfscript>




Clever.
But perhaps you should TEST your code. Then you would see that form information is not preserved.

Anyway, TP is asking for help on a dubious endeavor. The only real need, for which, is malicious hacking.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

> Anyway, TP is asking for help on a dubious endeavor. The only real need, for which, is malicious hacking.
Perhaps. However, there can be a legitimate need to forward some transaction details. We implement one like this

processPayPalTransaction.cfm
==========================
<!--- Process form post from PayPal. Run query to get client details --->
<cfscript>
getPageContext().forward("clientPayPalConfirmation.cfm");
</cfscript>

clientPayPalConfirmation.cfm
========================
Send client e-mail confirming receipt, plus relevant identifying information, with thanks. If transaction failed, confirm as well.

> Then you would see that form information is not preserved.
We forward the variables in Request scope, not in form scope.





Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

Thank you BKBK for your replies. As MikerRoo is entirely wrong, with his quick, rude and childish statements. I do have a legitimate reason for this request.
As you might know paypal has an IPN feature. This feature allows you to execute a script when a customer makes a purchase from you. Well, I have 2 pickupdepots for my customers and I need 2 different IPN scripts. Paypal only supports one, so I needed to use a NOTIFY_URL in the other website forms.
All works good UNTIL, if for some reason paypal cannot talk to your script on the FIRST try, paypal will try again later BUT it will do the rest of its retries using the DEFAULT IPN script link and does not retain the NOTIFY_URL that you originally sent it.
So what I need to do is just set a "CFIF" statement looking at the post from paypal and if it’s at the wrong url, to forward it to the other url.

I will try the <cfscript> you mentioned. (Thank You).
I have one quick question though, If I forward the request over from pickupdepot1 to pickupdepot2, Paypal requires a postback to authenticate the purchase, will that post back to paypal OR the sending link? (pickupdepot1)
If it does not carry over the feature to post back to paypal, that’s ok, because their both my scripts, so i can just do some CFIF's and trust one another.

Thanks alot for your help BKBK

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

Miker is 100% correct. You cannot use .forward to redirect to ANOTHER server. You can use CFLOCATION, but it can be only GET request (will loose posted data, unless you provide them in URL). Also, since the original post is not happening from a real user/browser, redirect may not work correctly, if PayPal does not process re-directs (because of security reasons, for example).

So, the only real opportunity you have in your situation is to use <cfhttp> to call the required page on your other server, wait for its response, post the confirmation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

As MikerRoo correctly pointed out, the above forwarding mechanism cannot send form-scoped variables. It can however forward the request scope. You can use that to forward all your form variables in one fell swoop, thus

pickupdepot1.cfm
===============
<!--- This block contains variables in form scope, say, form.x, form.y, etc --->
<cfscript>
Request.z = getHTTPRequestData().content;
getPageContext().forward("pickupdepot2.cfm");
</cfscript>

pickupdepot2.cfm
===============
<cfdump var="#Request#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

I Hate to sound Novice here but im just not sure of the code to use. I have reviewed the <http> tag and cannot figure out how to do what you mentioned Mr Black.
I however do understand what your saying, that the CFLOCATION will not work because of the Form POST vars will be lost.
My code now on pickupdepot1 will proccess the Paypal security feature like this:
<cfhttp url="https://www.paypal.com/cgi-bin/webscr?#str#" method="get" resolveurl="false">
</cfhttp>
(this is a post back to Paypal to see if the payment is legit)

Then If all is good (<cfif #cfhttp.filecontent# is "verified">), the payment at this point is truly coming from paypal and has passed the security)
Now that the security check is completed, I can send the form fields to another server.
I do also have right below that line this:
<cfloop index="locfield" list="#form.fieldnames#">
<cfset locfield=urldecode(evaluate(locfield))>
</cfloop>
This is to convert the posted variables to local variables. Will that help me or does that not matter?
Im just not sure of the <http> syntax to send the posted data to another url. For some reason its just not hitting me.

Tony




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

At this point you know the entire story about the payment. So, you can post whatever you want. If you are not sure about the syntax, perhaps, the documentation will help you. It is not so different from what you already doing with PayPal confirmation. Maybe the original value of STR plus some variable that holds confiramtion status. And, by the way, you can use GET for this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

Ok, Thanks for everyones help.

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

Im just not sure of the <http> syntax to send the posted data to another url. For some reason its just not hitting me.

This works. Try it.

pickupdepot1.cfm
===============
<!--- The CFHTTP to PayPal has just run. This block contains variables from PayPal in form scope, say, form.x, form.y, etc --->
<cfscript>
Request.z = getHTTPRequestData().content;
getPageContext().forward("pickupdepot2.cfm");
</cfscript>

pickupdepot2.cfm
===============
<cfdump var="#Request#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2006 Jun 12, 2006

Copy link to clipboard

Copied

You cannot use .forward to redirect to ANOTHER server.
Mr Black, I thought TonyP sought to redirect to another page, not to another server. Your point, that forward() is not a solution from one server to another, is correct. However, I cannot see any advantage in carrying out the process on two servers.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 13, 2006 Jun 13, 2006

Copy link to clipboard

Copied

I will try the forward() script. The links are like this: " http://www.pickupdepot1.com/ipnscript.cfm" would get forwarded to " http://www.pickupdepot2.com/ipnscript.cfm".

Will the forward() still work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 13, 2006 Jun 13, 2006

Copy link to clipboard

Copied

I will try the forward() script.
No need.

Will the forward() still work?
It wont, the reason being that the argument, x, in getPageContext().forward(x) must be a relative URL.

Here's a good way to pass form variables from one server, pickupdepot1, to another, pickupdepot2. While you're on pickupdepot1, store the form variables to a database. At pickupdepot2, read the variables from the database.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

Hi BKBI, I already save all the incoming data to a database. However I dont see that as being a feasable solution. I would have to ping the other server or something to let the other server know that there was a purchase for them and "come get it". Also would have to open a door for access from the other server.
Couldn't I somehow grab the form vars comming in and maybe wrap them in a wddx packet or somehow RE-proccess the form vars and the POST it to another url?I already have somehting like this:
<cfloop index="locfield" list="#form.fieldnames#">
<cfset locfield=urldecode(evaluate(locfield))>
</cfloop>
that converts the posted vars to local vars, So i know we can proccess the incomming vars. Now just what do we do with them. Maybe proccess them into a struct and then send the struct to another server?
One thing though, However it does it, The recieving end is looking for posted data from a form. I can change the script to allow ANY data from this other server, but it must be posted to this script.

There has to be a way that I can either roll up the form vars and the post it to another url, or bounce the post to another url. I wish i knew what it was.


Thanks

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

However I dont see that as being a feasable solution. I would have to ping the other server or something to let the other server know that there was a purchase for them and "come get it". Also would have to open a door for access from the other server.
All of that is not necessary at all. After processing the form, the first server only has to open the page on the second server that runs the query.

Couldn't I somehow grab the form vars comming in and maybe wrap them in a wddx packet or somehow RE-proccess the form vars and the POST it to another url?
If you insist that the variables must arrive at the second server as form-scoped variables, then proceed as follows. After receiving the form variables at pickupdepot1 dynamically create a new form whose action attribute is " http://www.pickupdepot2.com/ipnscript.cfm". Create a field with the same name as each field of the incoming form. Give each the value that corresponds to the name. For example,

<input type="hidden" name="ITEM_NAME" value="#FORM.ITEM_NAME#">

When the dynamic form is submitted to pickupdepot2, the variables will arrive there as form-scoped variables.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: BKBK
All of that is not necessary at all. After processing the form, the first server only has to open the page on the second server that runs the query.



You're quite right. Your suggestion should have worked for legitimate needs. (Although proper server configuration is the best solution)

That it didn't, means that TP is either a moron or a hacker (or both).

Form repost techniques, across servers, are used by phishers.
Do you want to help a hacker?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2006 Jun 14, 2006

Copy link to clipboard

Copied

To keep the quality of this forum high, Ill ignore MikerRoo.
I like the idea of just running a loop, proccessing the form vars as you said BKBK, Then I could use java to post the form to the other server.
That should work. Im diggin that idea.

Ill let you know how it goes, Thanks again

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2006 Jul 27, 2006

Copy link to clipboard

Copied

Hi BKBK, Thanks fo ryour help. Here is the solution that I used:
<cfif #form.business# eq "payments@mydomain.com">
<cfhttp method="Post" url=" http://www.mydomain.com/pickupdepot/ipnpage_cfpp.cfm">
<cfloop index="locfield" list="#form.fieldnames#">
<cfhttpparam type="Formfield" value="#urldecode(evaluate(locfield))#" name="#locfield#">
</cfloop>
<cfhttpparam type="Formfield" value="Verified" name="cfpp_verification">
</cfhttp>
<!--- The System has sent the data to The New Pickup Depot and now is going to Abort! --->
<cfabort>
</cfif>

This works great. It sends the data over then aborts.
Thanks for all your help

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2006 Jul 27, 2006

Copy link to clipboard

Copied

This works great.
Nice you found what you've been looking for; even nicer you found it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2006 Jul 27, 2006

Copy link to clipboard

Copied

LATEST
Most of the thanks goes to you for helping. I learned about CFHTTP and you steered me in the right direction.

Thanks Again.

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation