Why is my redirect not working within PHP?
<p>having trouble redirecting the user based on the $_GET</p>

<p>this file is called forgot.php</p>

<pre><code>&lt;?php 

       $mode_allowed = array('password');
       if (isset($_GET['mode']) === true &amp;&amp; in_array($_GET['mode'], $mode_allowed) === true) {
            echo $_GET['mode'];
       } else {
            header('Location: index.php');
            exit();
       }

?&gt;

&lt;form action="" method="post"&gt;
    &lt;div class="form-group"&gt;
          &lt;label class="sr-only"&gt;Email Address&lt;/label&gt;
          &lt;input type="text" name="form-emailaddress" placeholder="Email Address" class="form-emailaddress&gt;
          &lt;button type="submit" class="btn signin"&gt;Submit&lt;/button&gt;
    &lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>So based on the php code, what I believe it should do is that in the URL it should only accept <a href="http://localhost/forgot.php?mode=password" rel="nofollow">http://localhost/forgot.php?mode=password</a> </p>

<p>however if it's anything else then it should redirect. But what it does is if i change "mode" to something else or mode = "something" which is not in the array ($mode_allowed) then it just stays at the same page. </p>

<p>Thanks</p>