Forum Moderators: coopster
// Checks if the member_name and mem_pass has already been registered, redirect if not.
if (!isset($_SESSION['member_name']) &&!isset($_SESSION['mem_pass'])) {
$back_to_this_url = ($_SERVER['REQUEST_URI']);
$_SESSION['back_to_this'] = $back_to_this_url;
header("Location:" . SITE_ROOT . "restricted_resource.php");
} // close if (!isset...
?>
<HTML>
.
.
.
.
</HTML>
Question:
How do I change the header() part to this Javascript:
<SCRIPT language="JavaScript" type="text/javascript">
<!--
location.href="http://localhost/restricted_resource.php"
//-->
</script>
Actually, the header is already working and the script redirects to the restricted_resource.php. However, I am encountering problems with another script because of the header() command. So, I was wondering as to whether how to make the JavaScript run because when I tried this:
$url = (SITE_ROOT . "restricted_resource.php");
echo("<script language=\"JavaScript\" type=\"text/javascript\">");
echo("<!--");
echo("location.href=\"http://localhost/restricted_resource.php\"") ;
echo("// -->");
echo("</script>");
inserted in place of the header() command, it is not working.
Any advice or alternative solutions?
Sorry I know that this is kinda newbie, but, well, I am.
From what I can see all you need is
if (!isset...)
{ // not registered, use javascript to redirect
echo '<script type="text/javascript">'."\n";
echo '<!--'."\n";
echo 'location.href="http://localhost/restricted_resource.php"'."\n";
echo '// -->'."\n";
echo '</script>'."\n";
}