<html>
<body>
<h1><u>CMS Example #1</u></h1>
<ul>
<li>Find content item using 'nav' type <a href="index.php?id=1">click here</a>.</li>
<li>Dislay type 'page' with id '1' <a href="index.php?type=page&typeid=1">click here</a>.</li>
<li>Display login view <a href="index.php?display=login">click here</a>.</li>
</ul>
<?php
/* Enable error reporting */
error_reporting(E_ALL);
ini_set('display_errors', 1);
/* process input - create a variable for each input and assign the value*/
foreach($_REQUEST as $key => $value){ $$key = $value;}
/* process actions */
if(isset($action)){
echo "<p>PROCESSING ACTION...</p>";
if($action=="login"){
echo "<p>PROCESSING LOGIN...</p>";
unset($action);
echo "<p>LOGIN SUCCESS... REDIRECTING TO DASHBOARD</p>";
$display="dashboard";
}
}
/* find homepage */
$homepageid=1;
if(isset($display)){
if($display=="login") {
echo "<p>LOGIN VIEW<p>
<p>To login, please <a href='index.php?action=login'>click here</a>.";
}elseif($display=="dashboard") {
echo "<p>DASHBOARD VIEW</p>
<ul>
<li>To view all pages <a href='index.php?display=view&type=page'>click here</a>.</li>
<li>To add a new page <a href='index.php?display=add&type=page'>click here</a>.</li>
</ul>";
}elseif($display=="add") {
echo "<p>ADD VIEW</p>";
}elseif($display=="view") {
echo "<p>DISPLAY ALL VIEW</p>";
}
}elseif(isset($id)||(isset($type)&&isset($typeid))){
/* process nav to determine type & typeid */
if(isset($id)){
echo "<p>TRANSLATING NAV TYPE</p>";
/*for example only assign type=page and typeid=1*/
$type="page";
$typeid="1";
unset($id);
}
/* display content item */
echo "<p>DISPLAY CONTENT ITEM</p>";
echo "TYPE=".$type;
echo "ID=".$typeid;
}else{
/* display home page */
echo "<p>HOME PAGE</p>";
}
?>
</body>
</html>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Commented: