0

I'm trying to submit a drupal 6 form PIA to a third party site for processesing, but after submitting the form, I need to redirect to a thank you page within my own site.

I've read this post - Drupal form submission to a 3rd party website

but i'm nor sure how to set up the redirect properly. this is my code:

$form_state['#action'] = 'external site.com';

$form['#redirect'] = 'thankyou.com';

thanks

Community
  • 1
  • 1
StephanieF
  • 1,211
  • 1
  • 11
  • 19
  • This is really a shameless nudge, Since I still need help with this. I can make the form either submit to my third party processor correctly OR redirect to an internal page, but I still can't do both. I'd really appreciate some help. thanks – StephanieF Oct 17 '11 at 02:21

3 Answers3

0

Since I'm only trying to send informtaion to a third party and not actually redirecting the page after form submission to a third party site. I got the right answers tot he wrong question.

This is what I ended up using that worked for me:

$url = 'http://thirdpartyurl';
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$data = drupal_query_string_encode($pass_the_form_info);
drupal_http_request($url, $headers, 'POST', $data);
StephanieF
  • 1,211
  • 1
  • 11
  • 19
0

Redirect property is also set in $form_state.

$form_state['redirect'] = 'some.com';

Sibiraj PR
  • 1,481
  • 1
  • 10
  • 25
0

Make sure the redirect is the last step. Something like this:

function my_module_form {
  $form['#action'] = 'some.external.site';

  # Store the redirect in a value element, maybe we need some data
  # which are passed to the form, like a user ID, node ID etc.
  # So lets store the link in a value element
  $form['redirect_link'] = array(
    '#type'  => 'value',
    '#value' => url('some.redirect.page'),     
  );
}

function my_module_form_validate ($form, &$form_state) {
  # Do some validation stuff...
}

function my_module_form_submit($form, &$form_state) {
  # show some confirmation message...
  drupal_set_message(t('Successfully sent your data into space.'));

  # And finally the redirect...
  # The 'redirect_link' value was passed internally, without being sent
  # to the browser so we can safely use it.
  $form_state['redirect'] = $form_state['values']['redirect_link']
}
Max
  • 6,563
  • 4
  • 25
  • 33
  • 1
    Thanks for this answer, after working on it I realize I was asking the wrong question, I'm going to accept your answer since it's the right answer to the question I posted, thank you very much for the help! – StephanieF Jan 03 '13 at 15:25