All working here now:
accordion6.php
I just need to move the CAPTCHA error messages though, as the accordion panels are closed by default when the page reloads.
One thing I meant to ask though - with the CAPTCHA is it possible for the from not to lose everything the user has entered if they get the CAPTCHA code wrong?