On this page when the user registers it should do the insert, then set some session variables, then redirect the user to the profile page.
In your page what you do have for line 91, it looks like this:
$WA_redirectURL = "";
If you have the profile page specified here that is likely the problem. Since the script is designed to go to the profile page automatically after they are registered adding it into this line causes it to go to the page prematurely before the proper session variables are set.
To confirm the results you are getting and the status of the variables that should be set please add this code to the login page just above the text fields in code view:
var_dump($_SESSION);
This will let you know what session variables are set when the user comes to this page. Please post back with what you get.