Nothing to see here. What's happening is that the function is being declared twice, as the error message properly says.
Where are your require/include statements? Usually the cause of this sort of thing is some kinda of logic error that ends up including things twice. You might replace your includes, if any, with [man]require_once[/man] and see if that helps at all....
And why not use PHP header() instead of that ugly Javascript 🙁 .... oh, well, just kidding, really 😃