I'm wondering why you're using both JavaScript and PHP to validate your form. Why not just use PHP? The user may have turned off JavaScript in their browser.
The form continues to the page validate.php as this is the action of the from. It doesn't matter that you have a JavaScript alert box getting in the way. It will still go to validate.php as that's what the previous script told it to do.
If I were you. I'd have the following at the top of userpage.php
if (isset($_POST['submit']))
{
include ("validate.php")
}
Then, in the form do this:
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
This makes the form redirect the user to userpage.php, the same page that has the form. It then recognises that $_POST['submit'] is set. Then it includes validate.php which validates the selected variables. Include error messages in the validate.php script.
If all the variables are okay, then redirect the user with your header function. This also goes in your validate.php. If there is an error then an error message can be printed to the browser on the same page and the header function is not called as this follows in the else part of the conditional in validate.php. If there are no errors then the script moves to the header function and directs the user to the download page.
This way you keep your code separate from your HTML and you have the form's action instruction inside the same script as the form for your easy reference.
[EDIT]You could, to make it even cleaner code, incldue a functions page at the top of all pages that require form validation. Then in your functions.php page include the functions for error handling. Then simple replace include("validate.php"); with the name of the function in function.php.[/EDIT]