Skip to main content
Known Participant
January 22, 2013
Answered

CFHTTP with redirect

  • January 22, 2013
  • 1 reply
  • 1694 views

Hello,

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.

    This topic has been closed for replies.
    Correct answer Reed_Powell-ttnmOb

    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.

    hth

    reed

    1 reply

    Inspiring
    January 22, 2013

    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.

    -reed

    peterswanAuthor
    Known Participant
    January 22, 2013

    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.

    Pete

    Reed_Powell-ttnmObCorrect answer
    Inspiring
    January 22, 2013

    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.

    hth

    reed