I think there will be a simple solution to my problem but i'm new to PHP and i cant work it out.
basically my site only has 1 page index.php... and i have a small script that includes a page i set.
for example, if you go to ?p=contact, it will include the contact.php file into index.php
on a certain page i have a script that is initialized in the body tag, but i only want it to appear in the body tag when i go to that page so i created this script:
<?php
if ( $p == portfolio ) {
echo "<body onload=\"javascript:startmenu()\">";
} else {
echo "<body>";
}
?>
but the $p variable is defined after this further down the code, so its not reading it, well i think thats the problem.
the code i am using is this:
<?php
if (isset($_GET['p']) && $_GET['p'] != "") {
$p = $_GET['p'];
if (file_exists($p.'.php')) {
@include ($p.'.php');
} elseif (!file_exists($p.'.php')) {
@include ('404.php');
}
} else {
@include ('home.php');
}
?>
any ideas?