An explanation on using the header() function in PHP is here
, within the first answer.
Are you building this site for educational purposes, or for use in a production environment? If you're building a site for a production environment, I'd suggest that you have someone with a bit more experience look over it first. Improperly done could be both inefficient, and insecure. I'm not trying to be insulting or demeaning in any way, but I do recall going through this phase of coding years ago, and had to learn some lessons the hard way.