Since you didn't provide any code, it's impossible to know the problem without a crystal ball. Some users here have those, though, so maybe they can help.
It's not really a "redirect" if they're actually clicking a form button. It's then moved into the realm of form processing. Use the form's action attribute to point to the processing page. It should generate content appropriate for the location, or else you could actually redirect at this point.