Forum Moderators: coopster
the thought:
rather than
err='';
if (something not good) { $err=foo;}
if ($err!== '') {make page here including $err}
do:
if (something bad) {$_SESSION['errmsg']=foo; header 'location:error.php'}
error.php:
<?php include "includes/prehtml.php";
if(isset($_SESSION['errtitle'])){$title=$_SESSION['errtitle'];}
else{ $title="You Must Be Logged in to Access";}
include "includes/pagetop.php";
include "includes/header.php";?>
<body>
<?php include "includes/layoutbars.php";
if (isset($_SESSION['errmsg'])) {$errmsg=$_SESSION['errmsg'];}
else {$errmsg="It appears you have attempted to access parts of the site that require you to be logged in.
<br>You must register if you do not already have an account.<br>";
$userid= $_SESSION['userid'];
}?>
<div id="main">
<h1>Welcome</h1>
<?echo $errmsg;?></div><?php include "includes/footer.php";?>
Pertinent code calling error.php:
if (mysql_num_rows($verResult) ==0) {$errormsg="bad monkey.<br>not permitted.<br>";}//trimmed for brevity
if ($errormsg!==''){
$errtitle="ERROR - View Coin History";
$_SESSION['errtitle']= $errtitle; $_SESSION['errmsg'] = $errmsg;
header('Location: error.php');
}else {
unexpected result:
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0