PHP Switch and Login
<p>I'm fairly new with PHP and I am messing around with a login/registration system. I setup my sample website using a PHP-SWITCH script I found a while back:</p>

<pre><code>    &lt;?php
  switch($_GET['id']) {
  default: include('home.php');
  /* LOGIN PAGES  */
  break; case "register_form":
   include ('includes/user_system/register_form.php');
  }
 ?&gt;
</code></pre>

<p>On the registration page the form links to my "register.php" which checks the validity of the form and to check for any blank fields and so on. "register.php" is supposed to refresh the page and add a reason to what the user did wrong when submitting the form.</p>

<p>On my "register_form.php" page, which holds the actual form. This field is hidden until the user makes a mistake.</p>

<pre><code>    &lt;?php if (isset($reg_error)) { ?&gt;
  &lt;span class="red"&gt;&lt;?php echo $reg_error; ?&gt;&lt;/span&gt;, please try again.
 &lt;?php } ?&gt;
</code></pre>

<p>My "register.php" checks the form for all the errors. Here's the bit of code that will refresh the page with the reason for the error:</p>

<pre><code>    // Check if any of the fields are missing
 if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirmpass'])) {
 // Reshow the form with an error
 $reg_error = 'One or more fields missing';
 include 'register_form.php';
</code></pre>

<p>Now after I submit the form without any fields filled out I get the error code, but it refreshes to the actual "register_form.php". The problem with this is that because of my PHP-SWITCH script (helps me manage the site a lot easier) I don't have any formatting on that page. The actual URL to my "register_form.php" would be: "index.php?id=register_form". Now I have tried several different things such as changing it to:</p>

<pre><code>include 'index.php?id=register_form'
</code></pre>

<p>And also changing it to:</p>

<pre><code>header(location:index.php?id=register_form')
</code></pre>

<p>Unfortunately all this does is refresh the page without the reason for the error. I know this can be easily solved by just adding a Javascript Validator but I'd like to know if it is possible to refresh the page with the error using either "include" or "header()" while having a PHP-SWITCH script on the website.</p>
