PHP file won't run because of validation in html form
<p>I can't get my php file to run when i hit submit when I have custom validation. When I select other in my drop down box a text box appers. Once I hit submit it will not run my php file. If I select a value in my drop down without this custom validation my php file runs. </p>

<pre><code>&lt;body&gt;
&lt;form action="form-to-email.php" method="post" name="LeaveRequestPart1" id="LeaveRequestPart1"&gt;
    &lt;table class="LeaveRequestPart1" align="center"&gt;

&lt;tr&gt;
    &lt;td colspan="2"&gt;&lt;font color="red"&gt;*&lt;/font&gt;
        &lt;label&gt;Type of Leave&lt;/label&gt;
            &lt;select name="TypeOfLeave" id="TypeOfLeave" onchange =
           "if(this.value=='Other'{this.form['Other'].style.visibility='visible'}else {this.form['Other'].style.visibility='hidden'};"&gt;
                &lt;option value="N/A"&gt;&lt;/option&gt;                       
                        &lt;option value="Vacation"&gt;Vacation&lt;/option&gt;
                        &lt;option value="Illness"&gt;Illness&lt;/option&gt;
                        &lt;option value="FamilyIllness"&gt;Family Illness&lt;/option&gt;
                        &lt;option value="Bereavement"&gt;Bereavement&lt;/option&gt;
                        &lt;option value="PersonalWithPay"&gt;Personal - with pay&lt;/option&gt;
                        &lt;option value="PersonalWithoutPay"&gt;Personal - without pay&lt;/option&gt;
                        &lt;option value="JuryDuty"&gt;Jury Duty&lt;/option&gt;
                        &lt;option value="Military"&gt;Military&lt;/option&gt;
                        &lt;option value="Pallbearer"&gt;Pallbearer&lt;/option&gt;
                        &lt;option value="Professional" id="Professional"&gt;Professional&lt;/option&gt;
                        &lt;option value="Routine" id="Routine"&gt;Routine - overnight&lt;/option&gt;

                &lt;option value="Other"&gt;Other&lt;/option&gt;
            &lt;/select&gt; 
            &lt;input type="text" name="Other" id="Other" style="visibility:hidden;" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
        &lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>PHP Code</p>

<pre><code>&lt;?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "Form Error; You need to submit the form. ";
}

//Form Variables
$ID = $_POST['ID'];
$Name = $_POST['Name'];
$CampusLocation = $_POST['CampusLocation'];
$TypeOfRequest = $_POST['TypeOfRequest'];
$TypeOfLeave = $_POST['TypeOfLeave'];
$Other = $_POST['Other'];


   //Validate first
   if(IsInjected($SEmail))
   {
       echo "Bad email value!";
       exit;
    }

if(IsInjected($YEmail))
    {
        echo "Bad email value!";
        exit;
    }

$Email_subject = "Leave Request Submitted";

//Start of Email body. Do not remobe BODY commands
$Email_body = &lt;&lt;&lt;BODY

Employee ID: $ID
Name: $Name
Campus: $CampusLocation
Type of Request: $TypeOfRequest
Type of Leave: $TypeOfLeave
Other Type of Leave: $Other

Employee CCC email address: $YEmail@cccneb.edu
BODY;
//End of Email body

// single email address 

$to = "$SEmail@cccneb.edu";
$to2 = "$YEmail@cccneb.edu";


// multiple recipients
//$to  = 'YEmail@cccneb.edu' 

//Email From &amp; Reply
$headers = "From: $to2 \r\n";
$headers .= "Reply-To: $to2 \r\n";

//Send the email!
mail($to,$Email_subject,$Email_body,$headers);

//done. redirect to thank-you page.
header('Location: form-end.html');


// Function to validate against any email injection attempts
function IsInjected($str)
{
    $injections = array('(\n+)',
          '(\r+)',
          '(\t+)',
          '(%0A+)',
          '(%0D+)',
          '(%08+)',
          '(%09+)'
          );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
      {
          return true;
      }
  else
      {
          return false;
      }
}

?&gt; 
</code></pre>
