View Full Version : Pages...
09-17-2005, 05:40 AM
Ok, so, you know how you can use switch, or if, or arrays to make pages? like act=whateverpage?
well, can anyone give me a detailed explination of how the arrays method works?
oh and also, how do you make something like act=page&value=something?
thanks in advanced.
09-17-2005, 06:40 AM
querystring: script.php?page=page&action=do&value=whatever is access using the $_GET or $_REQUEST superglobals. Using $_GET['action'] on the above querystring will return a value of 'do' to the value.
Now, it depends on what you are doing for what would be the best method to use. If your planning on running an include() or require() I'd suggest you use both an array for the pages allowed, and a switch. If your embedding different actions into your script, I'd use an if statement.
Here's what I mean:
$allowed_pages = array ('index.php', 'members.php', 'news.php');
if (!empty($_GET['page']) AND in_array($_GET['page'], $allowed_pages))
include('./' . $_GET['page']);
die ('The page requested is not available.');
Not exactly the most secure, but would suffice. Now, for embedded, which is what I use most frequently:
$_REQUEST['action'] = 'default';
if ($_REQUEST['action'] == 'default')
// Default page code
if ($_REQUEST['action'] == 'shownews')
// Show the page news code
if ($_REQUEST['action'] == 'showarticle')
// Show just the article requested (we would need more varibles for this)
Does that help you any?
09-17-2005, 07:02 AM
actually, not exactly what I was looking for, but I'll use some other resources and work with that.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.