I am having trouble properly encoding URL data. Using the following code:
$redirect = drupal_urlencode("user/register?destination=/node/1");
drupal_goto( $redirect );
but, the URL that comes up in my browser test is the following:
http://testsite.com/user/register%253Fdestination%253D/node/1
I thought using the drupal_urlencode function should fix this encoding issue. How can I fix it?
You’d be better off using the built in
url()function to create your URL, if you pass an array as thequeryparameter it handles URL encoding for you:drupal_encode()will encode the whole string that you pass to it, so if you want to do it your original way it would look like this: