When validating forms and doing page redirection using the header function, I suggest to put your codes above the <html> tag or basically before the page is loaded. I believe you placed your codes below the <body> tag that's why the header function did not work or return an error message.