Page 2 of 2

Posted: Thu Oct 31, 2002 5:24 am
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..

Posted: Thu Oct 31, 2002 5:26 am
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

Posted: Thu Oct 31, 2002 5:39 am
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?

Posted: Thu Oct 31, 2002 5:42 am
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

Posted: Thu Oct 31, 2002 5:44 am
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

Posted: Thu Oct 31, 2002 1:43 pm
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 ;)

Posted: Thu Oct 31, 2002 3:13 pm
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.