4 Replies Latest reply on Jan 22, 2013 3:15 PM by peterswan

    CFHTTP with redirect

    peterswan Level 1



      I'm trying to have CFHTTP post to an action page on another website, but then I want the user to end up on that page. The reason for this is that after the user clicks submit, I need to process some information here on our server, then send the user to the action page. Is that possible?


      I know I could send a form back to the user, but before it displays, have JavaScript submit the form. However, this seems inefficient, also the information is sensitive, and I'd rather not send it back to the user at all.


      Thanks for any help.

        • 1. Re: CFHTTP with redirect
          Reed Powell Level 3

          CFHTTP doesn't return until the operation completes, so all you need to do is to execute the CFHTTP to POST to the page, then do a CFLOCATION to redirect the user.


          • 2. Re: CFHTTP with redirect
            peterswan Level 1

            So I post everything to the action page using CFHTTP, but then I have to redirect the user with the same variables in the URL?


            I would be double submitting the information that way. Plus, this is sensitive information. I don't want to use GET, I have to use POST.



            • 3. Re: CFHTTP with redirect
              Reed Powell Level 3

              CFHTTP doesn't send any traffic to the user.  It only sends between your CF server and the "other" server.  Sounds like you would do something like this:  Display form to your CF user.  User fills it out and hits SUBMIT.  You site gets the results of the FORM, does whatever it needs to do with it, and then uses CFHTTP to also send whatever information it needs to the "other" server.  It can do that using either GET or POST.  It then uses CFLOCATION to redirect the user to whatever page on your CF server you need to get him to.  If there is form information that needs to get passed on to that page, then you'll need to either save it in a database, or put it into session vars, if you want to avoid using URL vars to pass it along.  Best bet is to do as much of the form data processing on the CF page that runs when the user hits SUBMIT.




              • 4. Re: CFHTTP with redirect
                peterswan Level 1

                That seems like an accurate description of what CFHTTP does. I'll probably insert into my DB with an AJAX request called by a JavaScript function which runs when the user clicks Submit. After that's done, I'll submit the user to PayPal, with their choices.


                Thanks for your help,