Jump to content

The "abc.php?do=" function?


nonphixion

Recommended Posts

Hi all,

First post here, thank you all for this great resource, it's been of great use over the past few days :) I've tried searching for the subject-mentioned item but it doesn't do well as it just brings back everything with php in it ;)
[b]
My question is[/b], I have a main page (like most of you :) ) which has a lot of structure (through CSS) and I'd like to keep it as simple as possible when I create a new page. I've seen that some sites use www.domain.com/page.php?do=randompage function to pull up pages which I assume only contain the least information required (i.e. just content). Could someone please be kind enough to explain the structure of this or link to the correct tutorial (I don't know what keyword I need to search for it).

Many thanks in advance :)
Link to comment
Share on other sites

I dont quite understand what you are trying to achieve here, but do=randompage is done by sending a variable through the url, if you wish to use this to point to the name of your css file, do:
$cssfilename = $_GET['css'];

then you would be able to include your css file by adding its name at the end:
test.php?css=design.css

something like this...
Ted
Link to comment
Share on other sites

The do= is a URL variable

and that value is set to randompage in this example.

So all u do it place this code where you want the page to be echoed.

It's a bit like an iFrame in PHP

<?php
$do = $_GET['do'];
if($do == "") {$do2 = "main";} else {$do2 = $do;}

include $do . ".php";
?>

That should work sorry if i missed something, UI'm quite busy.
Link to comment
Share on other sites

when you have ?foo=bar in the url that is passing a variable to a script.

So in the example case www.domain.com/page.php will receive a variable called 'do' and that var is set to 'random'.

Somewhere in the script will probably be a switch statement like this:
[code]<?php
switch ($_GET['do')
{
case 'random':
 // do the random stuff
 break;
case 'this':
 // do this
 break;
case 'that':
 // do that
 break;
default:
 // do this if all other cases unmatched
}
?>[/code]
Link to comment
Share on other sites

Thank you all for the quick response. My apologies for not explaining myself better, should have provided an example:

http://www.totalbf2.com/ On the left nav the links will go through the same php file but possibly link to an html one? That's what I'm looking to understand as it seems it's a time saving way of building a site with many pages.

I will try out what's been posted to see if it's what I'm aiming for, many thanks again :) (I will revert)
Link to comment
Share on other sites

It's simply used to fill the main content portion of the page around head and footer templates (in the URL you provided anyway). Expanding on what the others were saying. The value of the ?do= is probably a filename or other signifier in the site that contains the main page contents. It's basically an easy way to manage template and content through PHP.

For instance, you have your main page:
[code]
<html>
<body>
Hello everyone!!!! You are now on page:

<?php
//Used to display main content within template framework
$contentfile = $_GET['do'] . ".php";
include_once('$contentfile');
?>

<br />
Thanks for visiting
</body>
</html>
[/code]

B
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.