I am busy learning PHP. However doing a small website with PHP where i control the Variables passed, i am stuck at a If statement issue.
Every internal page link i have passes a variable to control the content i pull from a database. even links from other internal pages to my Index.php page. The thing is the index.php page gives errors because there is a empty _Get issue when you enter the saite from external link. There are four pages. all other pages work with no errors but loading index page gives error.
My code:
$Section = $_GET['SID'];
if ( $Section == "HOME" ) {
$SectionTitle = 'Start';
$SectionID = 'HOME';
}
if ( $Section == "BDIR" ) {
$SectionTitle = 'Directory';
$SectionID = 'BDIR';
}
if ( $Section == "ACOM" ) {
$SectionTitle = 'Accommodation';
$SectionID = 'ACOM';
}
if ( $Section == "REST" ) {
$SectionTitle = 'Restaurants';
$SectionID = 'REST';
}
What i need to achieve is when there is an empty _Get its must assign the same value as the Home (First If) Values.
I have tried
if (!empty($_GET)) {
$SectionTitle = 'Start';
$SectionID = 'HOME';
}
and a few other variations with no luck.
But i think i am out of my league, as i wonder, should some if my statements not be within(under) other if statements here?
Thank you
Aucun commentaire:
Enregistrer un commentaire