Code block not getting executed
<p>I was trying to make a little report management system recently. Everything was going well till I encountered this weird problem. Since the code contains lots of html, I'll only include the important parts.</p>

<p>Basically this is a login page. I am storing the information in SESSION variable.</p>

<p>When the username and pass doesn't match, the error message is given to this below function for further processing.</p>

<p>Edit: Every page in my project includes a config.php with following contents</p>

<pre><code>// Start of config.php
session_start();
error_reporting(E_ERROR);

// ********************* Database Config **********************//
$dbHost = "localhost";          // MySQL host
$dbUser = "";   // MySQL username
$dbPass = "";   // MySQL password
$dbDatabase = "";  // MySQL main database name
</code></pre>

<p>A part of login.php is shown below.</p>

<pre><code>//START OF PHP CODE//
include("config.php");

    function gotError($msg)
    {
        $_SESSION['err'] = $msg;
        header("Location: login.php");
        die();
    }

//CODE FOR EVALUATION OF DATA//

// END OF THE PHP CODE &amp; BELOW THE HTML WILL START //
</code></pre>

<p>And on the same page, below the starting php code, there is the html code of page. Between the html, there are some bits of php code for using the data set above.</p>

<pre><code>----------- SOME HTML CODE HERE----
         &lt;?php

         if(isset($_SESSION['err']))
         {
         $html.= "&lt;script type='text/javascript'&gt;";
         $html.= '$.alert("'.$_SESSION['err'].'");';
         $html.= "&lt;/script&gt;";
         print $html;
         }
        ?&gt;
----------------- SOME HTML CODE HERE--------
</code></pre>

<p>Now here's the weird behavior comes in. The page post the login data to itself &amp; if error occurs, the error is set in session variable { $_SESSION['err'] } and then redirected to itself again which displays a jquery message box if $_SESSION[ 'err' ] is not empty.</p>

<p>The above code doesn't work in the original form, however, if I do like code shown below, the code works. I mean the whole code including the conditional components which didn't worked previously. As soon as I remove that particular line, the conditional evaluation doesn't work.</p>

<pre><code>     &lt;?php
     print($_SESSION['err']);

     if(isset($_SESSION['err']))
     {
     $html.= "&lt;script type='text/javascript'&gt;";
     $html.= '$.alert("'.$_SESSION['err'].'");';
     $html.= "&lt;/script&gt;";
     print $html;
     }
    ?&gt;
</code></pre>

<p>Does anyone have a clue about this? I am using PHP Version 5.3.8.</p>

<p>Thank You.</p>
