Download it and work it out..! If you can..!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

Post by Darkside »

So then on my index.php

I Have:

$_GET['page'] = trim($page);
if (empty($page)) {
$_GET['page'] = "home";
}


//That a load of crap.. init..?

and on my include Ive got ..

<?php include ("flash/$_GET['page'] ") ; ?>


I'm lost in the woods.. and its all dark..
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

No, you don't want to use $_POST - that's for forms that you posted using the POST method, you want to use $_GET which is for things that are in the query string, like your page variable, try:

Code: Select all

foreach ($_GET as $key =&gt; $value) {
    $_GET&#1111;$key] = trim($value);
}
at the top of your PHP script, and then

Code: Select all

if (!empty($_GET&#1111;'page'])) { 
    $page = $_GET&#1111;'page'];
} else {
    $page = 'put whatever you want your default page to be here';
}
instead of

Code: Select all

$page = trim($page); 
if (empty($page)) { 
$page = "news"; 
}
Then you should be able to do:

Code: Select all

include $page.'.php';
Mac
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

Post by Darkside »

Thank you god..!

Only think now it if I want the

<?php include $page.'.php'; ?>

To direct to a sup folder eg

<?php include page/$page.'.php'; ?>


How would I do that cus above does not work?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to change it to:

Code: Select all

include 'page/'.$page.'.php';
notice how the strings like page/ and .php have to be in quotes and that the variable $page does not. The different parts are concenated (joined together) using fullstops (.'s).

Mac
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

Post by Darkside »

lol thank you v.much I get it now..

I learn more about php in these last 5 minutes then I have for like to 4 month Ive been learning, rofl
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

and no offense intended man, but to say stuff like "thanks a lot you gurus" isn't really going to get a lot of help from anyone. only thing it's going to cause is people to get hard feeling towards ya, and just say "hrm, let him figure it out himself then".

Just a suggestion ;)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

"hrm, let him figure it out himself then"
isn't that bad, is it?
I think it's always more useful (for all) to only point to some directions and then let them figure it out for themselfs.
e.g. only providing links to manual/tutorials/other threads is no offense at all.
  • There are (at least) three reasons for that
  • obviously covered in manual/tutorials/other threads
  • question of general nature, taking too much place here
  • I don't really know, but this sounds reasonable ;)
I stop posting to a thread when I think my suggestions do not work out (why ever), someone else today has the patience of job or simply is better at this topic (or even simpler I forgot it - bad bad "mark all topics read" ;) )
Too many cooks spoil the broth.
Post Reply