Jump to content

reading a post without going out on index.php


nielcleo
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...