Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Aha, the question I have been waiting for. I'm working on a site that does just this. First, you got to separate your site into pages (each page has a different layout). For example, to logout, you would have something like this: sitename.com/?action=logout</p> <p>To go home, you could go to sitename.com, if you try /?p=somethingThatDoesntExist then you still get to the homepage (or an error page)</p> <p>If you have access to something underneath your web root, then it's much better. Then, you should keep all .php files in /root/content/ and only one index.php in /root/www/ </p> <p>This code is what I use to give the player a page if he is logged in (and optionally if he is an admin)</p> <pre><code>// Check if alternate page requested if (!empty($_GET["p"]) and !empty($_SESSION['id'])) { $page = $_GET["p"]; if (!empty($pages[$page])) { $page_array = $pages[$page]; if ( (!empty($page_array['auth'])) &amp;&amp; ($user['Auth'] &lt; $page_array['auth']) ) { $page_array = $pages['index']; } } else { $page = ''; } } </code></pre> <p>Then, you do your basic stuff:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang='en'&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;&lt;? echo $page_array['title'] ?&gt;&lt;/title&gt; &lt;link rel="stylesheet" href="css/3p/reset.css" type="text/css"/&gt; &lt;link rel="stylesheet" href="css/3p/formalize.css" type="text/css"/&gt; &lt;link href="css/bootstrap.css" rel="stylesheet"&gt; &lt;link href="css/main.css" rel="stylesheet"&gt; &lt;link href="css/bootstrap-responsive.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require("../content/header.php"); require($page_array['require']); require("../content/footer.php"); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here are the contents of page_array:</p> <pre><code>$pages = Array(); $pages['admin'] = Array( 'auth' =&gt; 3, 'require' =&gt; "../admin/index.php", 'title' =&gt; "Administration - NPG CP" ); $pages['index'] = Array( 'require' =&gt; "../content/index.php", 'title' =&gt; "Home - NPG CP" ); $pages['friends'] = Array( 'require' =&gt; "../content/index.php", 'title' =&gt; "Friends - NPG CP" ); $pages['pm'] = Array( 'require' =&gt; "../content/index.php", 'title' =&gt; "Messages - NPG CP" ); $pages['stats'] = Array( 'require' =&gt; "../content/index.php", 'title' =&gt; "Statistics - NPG CP" ); </code></pre> <p>On my site, I only use one viewable file that handles everything else. I hope I helped you. I can give you the source code to my site, just email me at [my_username]@gmail.com for it :)</p>
 

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