Skip to main content
Known Participant
June 10, 2006
Question

Form Redirect

  • June 10, 2006
  • 18 replies
  • 1656 views
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
This topic has been closed for replies.

18 replies

TonyPAuthor
Known Participant
June 12, 2006
Ok, Thanks for everyones help.

Tony
Participating Frequently
June 12, 2006
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.
TonyPAuthor
Known Participant
June 12, 2006
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




BKBK
Community Expert
Community Expert
June 12, 2006
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#">

TonyPAuthor
Known Participant
June 12, 2006
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
Participating Frequently
June 12, 2006
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.
BKBK
Community Expert
Community Expert
June 12, 2006
> 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.





BKBK
Community Expert
Community Expert
June 11, 2006
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>



June 11, 2006
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.

June 10, 2006
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.