Jump to content

reading a post without going out on index.php


nielcleo

Recommended Posts

Hii have a simple index.php displaying a topic title and a brief summary of the content. And in the topic title has a link like this href="view_post.php?id=$id"which this url calls the view_post.php file.. it has anyway to make this still in the index.php instead of calling the view_post.php file..

Link to comment
Share on other sites

yeah, you can add a query to the url to let index.php know which action you want it to do, eg:

index.php?action=view_post&id=$id

then inside index.php:

$action = isset($_GET['action']) ? $_GET['action'] : false;if ($action == 'view_post') {	//}else {	//}

you might want to put all the action files into a folder, but still have the client go through index.php, in which case you could do:

$validActions = array('view_post');$action = isset($_GET['action']) ? $_GET['action'] : false;$action = $action !== false && in_array($action, $validActions) ? $action : false;if ($action !== false) {	include 'actions/'.$action.'.php';}else {	//}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...