I have a custom form which can be accessed from different places inside the website. The form itself is inside the admin overlay.
When the form is submitted, I want the user (administrator) to return to the place where he accessed the form. The form can also be accessed from within the overlay.
Inside the submit handler I use a form redirect to return but I don't have a clue how to determine the url of the previous page to return to.
// $_SERVER['REDIRECT_URL']?
$redirect = 'set redirect url'
$form_state['redirect'] = $redirect;