When you submit the form the $rsPATIENT->getColumnVal("PFpatientID") will not exist; what I do is create a hidden form field and bind $rsPATIENT->getColumnVal("PFpatientID") to it and then use the post value of the hidden field to redirect to the correct page.