2011-10-10 86 views
0

我想提交一個Drupal 6表單PIA到第三方網站進行處理,但提交表單後,我需要重定向到我自己的網站中的謝謝頁面。drupal6提交到第三方網站與內部重定向

我讀過這篇文章 - Drupal form submission to a 3rd party website

,但我也不知道如何正確設置重定向。 這是我的代碼:

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

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

謝謝

+0

這真是一個無恥的輕推,因爲我還需要這方面的幫助。我可以讓表單正確地提交給我的第三方處理器,或者重定向到一個內部頁面,但我仍然不能同時執行這兩個操作。我真的很感謝一些幫助。謝謝 – StephanieF

回答

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

感謝這個答案,在完成它之後,我意識到我問的是錯誤的問題,我會接受你的答案,因爲這是我發佈的問題的正確答案,非常感謝你的幫助! – StephanieF

0

重定向屬性也在$ form_state中設置。

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

0

由於我只是想送informtaion給第三方和表單提交後不實際重定向頁面到第三方網站。 我得到了正確的答案,他錯了。

這是我結束了使用爲我工作:

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