Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, here is my version of the CMS. You can find all my files here in a zip archive: <a href="http://chechi.be/midas/simple-cms.zip" rel="nofollow noreferrer">http://chechi.be/midas/simple-cms.zip</a>.</p> <p>This is the admin page:</p> <pre><code>&lt;?php session_start();?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;CMS&lt;/title&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;link rel="stylesheet" href="style.css" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="main"&gt; &lt;h1&gt;CMS&lt;/h1&gt; &lt;?php if (empty($_POST) &amp;&amp; isset($_GET['action'])) { $action = $_GET['action']; switch ($action) { case 'logout': session_unset(); session_destroy(); break; } } if (!isset($_SESSION['user'])) { $user = ''; $pass = ''; if (isset($_POST['login'])) { $user = strtolower(trim($_POST['user'])); $pass = $_POST['pass']; $errors = array(); if ($user == '' || $user != 'admin') { $errors['user'] = ''; } if ($pass == '' || $pass != '123456') { $errors['pass'] = ''; } if (empty($errors)) { $_SESSION['user'] = $user; } else { echo '&lt;p class="error"&gt;Please fill in your correct '; if (isset($errors['user'])) echo 'username'; if (count($errors) == 2) echo ' and '; if (isset($errors['pass'])) echo 'password'; echo '.&lt;/p&gt;', "\n"; } } } if (isset($_SESSION['user'])) { $user = $_SESSION['user']; ?&gt; &lt;div id="headertext"&gt; &lt;p class="l"&gt;You are logged in as &lt;strong&gt;&lt;?php echo $user?&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p class="r"&gt;&lt;a href="?action=logout"&gt;Logout&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;?php if (isset($_POST['edit'])) { if (file_put_contents('homecontent.txt', $_POST['homecontent']) !== FALSE) echo '&lt;p class="succes"&gt;Your changes are saved.&lt;/p&gt;', "\n"; } $homecontent = file_get_contents('homecontent.txt'); ?&gt; &lt;form method="post" action=""&gt; &lt;p&gt;Here you can edit your homepage text:&lt;/p&gt; &lt;textarea name="homecontent" id="homecontent" rows="20" cols="55"&gt;&lt;?php echo $homecontent?&gt;&lt;/textarea&gt; &lt;p&gt;&lt;button type="submit" name="edit"&gt;Save changes&lt;/button&gt;&lt;/p&gt; &lt;/form&gt; &lt;?php } else {?&gt; &lt;form method="post" action="" id="login"&gt; &lt;p&gt; &lt;label for="user"&gt;Username:&lt;/label&gt;&lt;input type="text" name="user" id="user" value="&lt;?php echo $user?&gt;" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="pass"&gt;Password:&lt;/label&gt;&lt;input type="password" name="pass" id="pass" value="&lt;?php echo $pass?&gt;" /&gt; &lt;/p&gt; &lt;p&gt; &lt;button type="submit" name="login"&gt;Login&lt;/button&gt; &lt;/p&gt; &lt;/form&gt; &lt;?php }?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload