PHP - Deny access to pages if not logged in
<p>im new to PHP and have just implemented a login script.</p>

<p>There is no register as its an internal site from only a select few people so i pre-defined them passwords in the database.</p>

<p>All is working ok they can log in and out, however there are pages i don't want viewable if you're not logged in.</p>

<p>They way i have gone about this is essentially checking to see if they are logged in and if they are, display the html to the links to be clicked on. However i get an error in the console: </p>

<p><em>Uncaught SyntaxError: Unexpected token }</em></p>

<p><strong>My index.php</strong></p>

<pre><code>&lt;?php

if (isset($_SESSION['loggedin']) &amp;&amp; $_SESSION['loggedin'] == true) 
{
    echo "&lt;div class='mainContainer' align='center'&gt;
    &lt;div class='noteSelectionBoxContainer'&gt;
        &lt;div class='custom-font' id='note-header-text'&gt;
            Choose your Note Category... &lt;br /&gt;
        &lt;/div&gt;
        &lt;div onclick='location.href='general_notes.php';' class='noteSelectionBox hvr-bounce-to-top1' id='selection-box1'&gt;
            &lt;div class='vertical-align-content'&gt;
                &lt;div class='noSelect'&gt;
                    &lt;div class='noteboxText custom-font'&gt;GENERAL NOTES&lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div onclick='location.href='template_notes.php';' class='noteSelectionBox hvr-bounce-to-top2' id='selection-box2'&gt;
            &lt;div class='vertical-align-content'&gt;
                &lt;div class='noSelect'&gt;
                    &lt;div class='noteboxText custom-font'&gt;TEMPLATE NOTES&lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div onclick='location.href='variable_notes.php';' class='noteSelectionBox hvr-bounce-to-top3' id='selection-box3'&gt;
            &lt;div class='vertical-align-content'&gt;
                &lt;div class='noSelect'&gt;
                    &lt;div class='noteboxText custom-font'&gt;REPLACE VARIABLES&lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;";
}
else
{
    echo "&lt;div class='custom-font' style='font-size: 18px;'&gt; Please log in to view the note categories.&lt;/div&gt;";
}

?&gt;
</code></pre>

<p>normally i can click on the div and the onclick kicks in and send me to the location defined.</p>

<p>Why is it saying Uncaught SyntaxError: Unexpected token }</p>

<p><a href="https://i.stack.imgur.com/P6bKU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P6bKU.png" alt="enter image description here"></a></p>