Iam making an app which has one index.php file. I also have these other pages:
contact_form_homepage.php
contact_form_config.php
contact_form_doc.php
contact_form_stats.php
contact_form_premium.php
Iam looking for a way I can have all the pages linked to the index.php such that whenever a user clicks Home it takes him to contact_form_homepage.php and whenever he clicks Config it takes him to contact_form_config.php and so on and forth
ie
<a href="http://apps.facebook.com/mtkenya-dev/index.php?p=contact_form_config&tab=contact_form_config&page_id=" title="contact_form_config" class="fbtab">Configuration</a>
Which php magic should I use? Kindly help
My usual technique is to include a php module. I usually put mine in site/ action
.php
You can see this at line 105 of the standard index.php from my framework.
// get the action
$ac=get_from_get('p');
$ua = "";
$is_mvc = 0;
// if no action specified this is the default action.
if ($ac=="")
$ac="login";
// attempt include the PHP for the action
$file = "site/$ac.php";
if (file_exists($file))
include($file);
else
{
header("HTTP/1.0 404 Not Found");
exit;
}
Simply do a link like you said above...
<a href="http://apps.facebook.com/mtkenya-dev/index.php?p=contact_form_config&tab=contact_form_config&page_id=2" title="contact_form_config" class="fbtab">Configuration</a>
Then you can read the page_id variable in php code with...
if($_GET['page_id'] == 2) {
header("Location: contact_form_config.php");
}
You can do one thing, depending on the query string paramter like "p=contact_form_config", you can load appropriate page in index.php file.
dg for when query string parameter is p=contact_form_config then you can use the below code
if($_GET['p'] == "contact_form_config ")
{
// you can load your page now
include_once('contact_form_config.php');
}
Hope this will be helpful :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.