Previously we talked about adding query strings for drupal_goto().
Drupal – Escape the Hex Characters in drupal_goto()
When the form is submitted, we can decide the redirect path in the form_submit() function.
Redirect to node/1 after form submission
function <form id>_submit($form, &$form_state) { $form_state['redirect'] = 'node/1' }
But if you want to redirect with query strings, the following piece of code will NOT WORK.
function <form id>_submit($form, &$form_state) { $form_state['redirect'] = 'node/1?abc=1&def=2#ghk' }
You will be redirected to node/1%3Fabc%3D1%26def%3D2%23ghk. Here is the CORRECT way to add query strings in the redirect path.
function <form id>_submit($form, &$form_state) { $form_state['redirect'] = array( 'node/1', array( 'query' => array( 'abc' => '1', 'def' => '2' ), 'fragment' => 'ghk', ), ); }
Done =)
Reference: Drupal forum – Redirecting with query string