Well the javascript function you want is window.location
and it's usage is just
window.location = "http://www.yoururl/";
so I guess if you really must do it you can probably just echo out a script that just does:
if ($bRedirect) //if we need to redirect
{
?>
<script language="javascript">
window.location = "http://www.yoururl/";
</script>
<?
}
or if you don't like breaking in and out of script
if ($bRedirect) //if we need to redirect
{
echo "<script language=\"javascript\">\n";
echo "window.location = \"http://www.yoururl/\";\n";
echo "</script>\n";
}
That should do it I think, I haven't tested it out, but if you have problems
just leave another message here. As to why it's bad, well preferably stuff like redirects you want to keep out of the hands of the client. For example what happens if, say a user has javascript disabled on their browser, or has a browser that doesn't support a specific javascript feature you're using?
Also, unless there's something really weird going on decisions like redirecting or denying access should be done first before any other work is done so that you don't do extra processing that will just be discarded.
Hope this helps,
-b