$category = isset($_POST['category']) ? strip_tags($_POST['category']) : null; $type = isset($_POST['type']) ? strip_tags($_POST['type']) : null; $pdate = isset($_POST['pdate']) ? $_POST['pdate'] : null; $acronym = isset($_SESSION['user']) ? $_SESSION['user']->acronym : null; // if user is NOT authenticated. if ($acronym == null) { echo <<<EOD <div style=" border: 1px solid #777; border-radius: 3px; padding: 10px 20px;"> <h2 style="margin-top: 0;">Du måste vara inloggad för att få skapa nytt innehåll...</h2> <p><a href="?p=clogin" class="aButton">Logga in</a></p> </div> EOD; } else { if ($create) { $cont = new CContent($urbax['database']); if ($newId = $cont->add($title, $category, $type, $pdate)) { echo "Nytt innehåll sparat. <a href='?p=uppdatecontent&id={$newId}' class='aButton'>Editera</a>"; //use javascritp to redirect - forces the the nav menu to uppdate echo "<script> setTimeout(function (){ window.location.href = '?p=contentedit'; }, 2000);</script>"; } } else { $today = date("Y-m-d"); //var_dump($user->isAdmin()); $disabled = ''; $info = ''; if (!$user->isAdmin()) { $disabled = "disabled"; $info = "<p> Du kan inte editera eftersom du inte är administratör.</p>"; } echo <<<MYHTML <div style=" border: 1px solid #777; border-radius: 3px; padding: 10px 20px;">