PHP includes

Sup guys. New member here, first time posting…
I’m a bit of a n00b concerning PHP and XML and all that, so I’ll probably be asking questions on here quite often.

I’ve got a site under development with a toolbar set on every page as a PHP include. The thing I want to avoid is somebody typing in the address of the toolbar.php page and pulling up the toolbar itself. If they do so, I’d like it to forward to the root page.

I’ve tried putting this tag at the top of my include:

<?php
header("Location: http://example.com");
?>

It forwards the included PHP to my root page, but then on my root page the toolbar doesn’t display properly anymore. Instead I get:

Warning: Cannot modify header information - headers already sent by…

Any help is appreciated :wink: