# global\_variable=off --\> declaration of variable?

**URL:** <https://forum.kirupa.com/t/global-variable-off-declaration-of-variable/118534>\
**Category:** Uncategorized\
**Created:** [August 6, 2004, 1:07pm UTC](https://forum.kirupa.com/t/global-variable-off-declaration-of-variable/118534 "2004-08-06T13:07:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjellaksel](https://avatars.discourse-cdn.com/v4/letter/f/47e85d/32.png) [@fjellaksel](https://forum.kirupa.com/u/fjellaksel)\
**Post date:** [August 6, 2004, 1:07pm UTC](https://forum.kirupa.com/t/global-variable-off-declaration-of-variable/118534/1 "2004-08-06T13:07:27Z")

</div>

Hi guys…

I use a include script on my index page, so all pages are loaded into the index page… yeah, you probably know what I am talking about… like:  
index.php?page=photos … but, the server that the site is hosted on has the global\_variable set to off, and it won’t work if I do not declare my variables first… at least, that’s what they say… Below is the code, and I hope that someone can tell me what I have to change to get it to work…

* * *

\<?php  
$IncludeDir = “inc\_files”;  
$DefaultPath = “inc\_files/bilder.inc”;  
$FileExtension = “.inc”;  
if (isset($side)) {  
$side = stripslashes(strip\_tags($side));  
$Forbidden1 = ereg("../", $side);  
$Forbidden2 = ereg("/", $side);  
$IncludePath = $IncludeDir . “/” . $side . $FileExtension;  
if ($Forbidden1 OR $Forbidden2) {  
echo “\<h1\>Warning\</h1\>  
“;  
echo “\<p\>Forespørsler på tvers av definerte  
“;  
echo “områder er ikke tillatt.\</p\>  
“;  
}  
else {  
if (@fopen(”$IncludePath”, “r”)) {  
include (”$IncludePath”);  
}  
elseif (!(@fopen(”$IncludePath”, “r”))) {  
echo “\<p\>Denne siden finnes ikke!\</p\>  
“;  
}  
}  
}  
else {  
include(”$DefaultPath”);  
}  
?\>

* * *

Hope someone can help me out here…

Best Regards  
Eirik Fjellaksel

---

<div class="post-metadata">

**Author:** ![Hans\_Kilian](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Hans\_Kilian](https://forum.kirupa.com/u/Hans_Kilian)\
**Post date:** [August 6, 2004, 3:33pm UTC](https://forum.kirupa.com/t/global-variable-off-declaration-of-variable/118534/2 "2004-08-06T15:33:36Z")

</div>

Heja Norge! 😉

Basically it means that instead of _$side_ you have to write either _$\_GET[‘side’]_ or _$\_POST[‘side’]_ depending on whether the page was activated by the HTTP GET or POST method.

In your case it’s the GET method so you should use this code:

```php

<?php
$IncludeDir = "inc_files";
$DefaultPath = "inc_files/bilder.inc";
$FileExtension = ".inc";
if (isset($_GET['side'])) {
$side = stripslashes(strip_tags($_GET['side']));
$Forbidden1 = ereg("\.\./", $side);
$Forbidden2 = ereg("/", $side);
$IncludePath = $IncludeDir . "/" . $side . $FileExtension;
if ($Forbidden1 OR $Forbidden2) {
echo "<h1>Warning</h1>
";
echo "<p>Foresp&oslash;rsler p&aring; tvers av definerte 
";
echo "omr&aring;der er ikke tillatt.</p>
";
}
else {
if (@fopen("$IncludePath", "r")) {
include ("$IncludePath");
}
elseif (!(@fopen("$IncludePath", "r"))) {
echo "<p>Denne siden finnes ikke!</p>
";
}
}
}
else {
include("$DefaultPath");
}
?>

```
