most likely the foldername query string variable isn't included as part of the forms action.
Set the action to:
action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>"
this will cause the from to include any query string variables when posting.