title: PHP Getting error for $page = $_GET['page'];
body: <p>This is my entire code. Shared to you.</p>
  
  <p>This is my error:</p>
  
  <pre><code>Notice: Undefined index: page in /export/home/dynamic/index.php on line 20
  </code></pre>
  
  <p>I can't seem to figure out why I keep getting this error. It is not the first time, I've suspected that it is the array but I don't know what to do with it.</p>
  
  <p>It's suppose to make a dynamic change page to my website. 
  I've had errors before where I make a global varible like <code>$page = $_GET['page'];</code></p>
  
  <p>I am open to any kind of answer and I am greatful to every single on of them.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Website&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;header&gt;Header&lt;br /&gt;
  &lt;nav&gt;
  &lt;a href="index.php?page=index"&gt;INDEX&lt;/a&gt;
  &lt;a href="index.php?page=page1"&gt;Startsida&lt;/a&gt;
  &lt;a href="index.php?page=page2"&gt;Anteckningar&lt;/a&gt;
  &lt;a href="index.php?page=page3"&gt;Kontakt&lt;/a&gt;
  &lt;!-- &lt;a href="index.php?page=faq"&gt;FAQ&lt;/a&gt; --&gt;
  &lt;/nav&gt;&lt;/header&gt;
  
  &lt;div id="content"&gt;
  &lt;?php 
  
  // Place the value from ?page=value in the URL to the variable $page. 
  $page = $_GET['page']; 
  
  // Create an array of the only pages allowed. 
  $pageArray = array( 
         'index', 
         'page1', 
         'page2', 
         'page3', 
         'faq' 
           ); 
  
  // If there is no page set, include the default main page. 
  
  if (!$page) { 
    include('pages/index.php'); 
  } 
  
  // Is $page in the array? 
  $inArray = in_array($page, $pageArray); 
  
  // If so, include it, if not, emit error. 
   if ($inArray == true) { 
    include('pages/'. $page .'.php'); 
  }else { 
    echo 'Umm tisk tisk. You should not be messing with things.'; 
  } 
  ?&gt; 
  &lt;/div&gt;
  
  &lt;footer&gt;Footer&lt;/footer&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>IT IS SOLVED!
  Thanks to hek2mgl my code now works properly. </p>
  
  <p>I want to thank the rest for submitting your answers to my problem. I owe you guys.</p>