Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to make a new request to process the php code. If the problem is only with URL address:</p> <p>You can make a ajax/iframe request to keep the same address:</p> <p><strong>Ajax</strong></p> <p>index.php</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; PHP Includes &lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function loadContent(page) { $.ajax({ url: "includes.php?page=" + page, complete: function(response) { $('#content').html(response); } }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt; This is the home page &lt;/h1&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="javascript:loadContent('page1')"&gt;Page1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="javascript:loadContent('page2')"&gt;Page2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="javascript:loadContent('page3')"&gt;Page3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="content" style='width:300px; height: 200px; border: 1px solid #000;'&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; // loading default page loadContent('page1'); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>includes.php</p> <pre><code>&lt;?php error_reporting(E_ALL ^ E_NOTICE); $page = $_GET['page']; $pages = array('page1', 'page2', 'page3'); if (!empty($page)) { if(in_array($page,$pages)) { $page .= '.php'; include($page); } else { echo 'Page not found. } } else { include('page1.php'); } ?&gt; </code></pre> <p><strong>Iframe (without use of javascript)</strong></p> <pre><code>&lt;li&gt;&lt;a href="includes.php?page=page1" target="iframe_id"&gt;Page1&lt;/a&gt;&lt;/li&gt; </code></pre> <p>OR you can make use of <strong>friendly URL</strong> (mod_rewrite in apache2):</p> <pre><code>&lt;li&gt;&lt;a href="includes/page1"&gt;Page1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="includes/page2"&gt;Page2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="includes/page3"&gt;Page3&lt;/a&gt;&lt;/li&gt; </code></pre> <p>more about friendly url <a href="https://www.google.com.br/search?q=mod_rewrite+example&amp;oq=mod_rewrite+example&amp;aqs=chrome.0.69i57j0l3j69i62l2.4445j0&amp;sourceid=chrome&amp;ie=UTF-8#bav=on.2,or.r_cp.r_qf.&amp;fp=5821160854c2fd50&amp;q=mod_rewrite+friendly+url+example" rel="nofollow">googling</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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