Escaping special characters in custom submit handler redirect URL? My submit handler contains a redirect to a URL formatted thus:

mysite.com/node/123/edit?step=step_2


and my problem is that it's appearing in the browser bar as:

mysite.com/node/123/edit%3Fstep%3Dstep=step_2


which messes up my redirect.

How do I escape the characters "=" and "?" for use in a URL for redirection from a custom submit handler?
If you use an array as the value for $form_state['redirect'], it will eventually be passed to url(). So you can use the same options as for that function to build up a structured query string:

$path = 'node/' . $nid . '/edit';
$query = array('step' =&gt; 'step_2');
$form_state['redirect'] = array($path, array('query' =&gt; $query));


There's more explanation in the documentation for the drupal_redirect_form() function.