drupal6提交到内部重定向的第三方网站

时间:2011-10-10 16:57:02

标签: drupal-6 drupal-fapi

我正在尝试将drupal 6表格PIA提交给第三方网站进行处理,但在提交表单后,我需要重定向到我自己网站内的感谢页面。

我已阅读此帖 - Drupal form submission to a 3rd party website

但我也不确定如何正确设置重定向。 这是我的代码:

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

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

感谢

3 个答案:

答案 0 :(得分:0)

Redirect属性也在$ form_state中设置。

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

答案 1 :(得分:0)

确保重定向是最后一步。像这样:

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']
}

答案 2 :(得分:0)

由于我只是尝试向第三方发送通知,而不是在表单提交到第三方网站后实际重定向页面。 在错误的问题上,我得到了正确的答案。

这是我最终使用的对我有用的东西:

$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);