On submit , php contact form gives 500 http error-ThrowExceptions

Exception or error:

Here is the code i did for contact form.. please check and help me what’s wrong in it.. i tried many solutions from the google but no one helped me much… thankyou.. on form submit this code gives me a 500 http error..
this code is form handler code which I used on form submit.

<?php
    function ValidateEmail($email)
    {
       $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
       return preg_match($pattern, $email);
    }
    if (isset($_POST['submit']))
    {
       $mailto = 'gakharc@gmail.com';
       $mailfrom = isset($_POST['contact-email']) ? $_POST['contact-email'] : $mailto;
       $subject = 'Website Contact';
       $message = 'Values submitted from web site form: ';
       $success_url = 'thankyou.php';
       $error_url = 'error.php';
       $error = '';
       $eol = "\n";
       $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
       $boundary = md5(uniqid(time()));
       $header  = 'From: '.$mailfrom.$eol;
       $header .= 'Reply-To: '.$mailfrom.$eol;
       $header .= 'MIME-Version: 1.0'.$eol;
       $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
       $header .= 'X-Mailer: PHP v'.phpversion().$eol;

    if (strtolower($_POST['code']) != '9') {die('Wrong CAPTCHA Answer');}

    if (!ValidateEmail($mailfrom))
       {
          $error .= "The specified email address is invalid!\n<br>";
       }

    if (!empty($error))
       {
          $errorcode = file_get_contents($error_url);
          $replace = "##error##";
          $errorcode = str_replace($replace, $error, $errorcode);
          echo $errorcode;
          exit;
       }

       $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
       $message .= $eol;
       $message .= "IP Address : ";
       $message .= $_SERVER['REMOTE_ADDR'];
       $message .= $eol;
       foreach ($_POST as $key => $value)
       {

    if (!in_array(strtolower($key), $internalfields))
          {
             if (!is_array($value))
             {
                $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
             }
             else
             {
                $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
             }
          }
       }
       $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
       $body .= '--'.$boundary.$eol;
       $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
       $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
       $body .= $eol.stripslashes($message).$eol;

    if (!empty($_FILES))
       {
           foreach ($_FILES as $key => $value)
           {
              if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
              {
                 $body .= '--'.$boundary.$eol;
                 $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
                 $body .= 'Content-Transfer-Encoding: base64'.$eol;
                 $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
                 $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
              }
          }
       }
       $body .= '--'.$boundary.'--'.$eol;

    if ($mailto != '')
       {
          mail($mailto, $subject, $body, $header);
       }
       $header('Location: '.$success_url);
       exit;
    }
    ?>

this is my form code.. sorry its a bit long but its requirments

<form id="quote-request" action="form-handler.php" method="post">

<div class="section-head">Contact Information</div>
<div class="form-row"><label>Contact Name: </label><input type="text" name="contact-name" placeholder="Enter your full name" required></div>
<div class="form-row"><label>Email: </label><input type="text" name="contact-email" placeholder="email address" required></div>
<div class="form-row"><label>Telephone: </label><input type="text" name="contact-phone" placeholder="Contact phone number"></div>
<div class="form-row"><label>Fax: </label><input type="text" name="contact-fax" placeholder="fax number, if available"></div>

<div class="section-head">Loan Request Information</div>
<div class="form-row"><label>Loan Requested: </label><input type="text" name="loan-amount" placeholder="Loan amount requested"></div>
<div class="form-row"><label>Loan Term Requested: </label><input type="text" name="loan-term" placeholder="Loan term requested"></div>
<div class="form-row"><label>Credit Scores: </label><input type="text" name="credit-scores" placeholder="like &quot;650, 725, 750&quot;, if known"></div>
<div class="form-row"><label>Property Address: </label><input type="text" name="property-address" placeholder="full property address with zip code"></div>
<div class="form-row"><label>Property Condition: </label><input type="text" name="property-conditon" placeholder="like &quot;Fair, Good, Excellent&quot;"></div>
<div class="form-row"><label>Property Description: </label><input type="text" name="property-description" placeholder="like &quot;Aparment Building, Mixed Use, Retail&quot;"></div>
<div class="form-row"><label>Is Property Legally Conforming?: </label><input type="text" name="legally-conforming" placeholder="Use Match C/O?"></div>

<div class="section-head">Purchase Information (for new purchase loan requests)</div>
<div class="form-row"><label>Contract Price: </label><input type="text" name="contract-price" placeholder="contract price at purchase"></div>
<div class="form-row"><label>Contract Date: </label><input type="text" name="contract-date" placeholder="date contract signed"></div>
<div class="form-row"><label>Is Property Occupied?: </label><input type="text" name="property-occupied" placeholder="enter percentage occupied"></div>
<div class="form-row"><label>Fair Market Value: </label><input type="text" name="fair-value" placeholder="current fair market value"></div>
<div class="form-row"><label>Cash and Reserves Available: </label><input type="text" name="cash-reserves" placeholder="cash reserves after purchase"></div>

<div class="section-head">Owner / Borrower Information</div>
<div class="form-row"><label>Property Owner: </label><input type="text" name="property-owner" placeholder="Titled property owner(s)"></div>
<div class="form-row"><label>Purchase Date: </label><input type="text" name="purchase-date" placeholder="Original Purchase Date"></div>
<div class="form-row"><label>Original Cost: </label><input type="text" name="original-cost" placeholder="Original Contract Price"></div>
<div class="form-row"><label>Current Market Value: </label><input type="text" name="current-market-value" placeholder="Fair market value"></div>
<div class="form-row"><label>Mortgage Balance: </label><input type="text" name="mortgage-balance" placeholder="Current Mortgage Balance"></div>
<div class="form-row"><label>Interest Rate:  </label><input type="text" name="interest-rate" placeholder="Current Interest Rate"></div>
<div class="form-row"><label>Current Lender Name: </label><input type="text" name="lender-address" placeholder="Current lender name"></div>

<!-- BEGIN PROPERTY INCOME AND EXPENSES PORTION-->
<div class="section-head">Property Income and Expenses</div>
<div class="section-head">Annual Property Expenses</div>
<div class="form-row"><label>Real Estate Taxes: </label><input type="text" name="property-taxes" placeholder="Annual Property Taxes"></div>
<div class="form-row"><label>Property Insurance:</label><input type="text" name="property-insurance" placeholder="Annual Property Taxes"></div>
<div class="form-row"><label>Electricy: </label><input type="text" name="electricy" placeholder="Annual electricty"></div>
<div class="form-row"><label>Fuel Oil: </label><input type="text" name="fuel-oil" placeholder="Annual fuel oil"></div>
<div class="form-row"><label>Gas: </label><input type="text" name="gas" placeholder="Annual gas"></div>
<div class="form-row"><label>Water Sewer Charges: </label><input type="text" name="water-sewer" placeholder="Annual Water Sewer"></div>
<div class="form-row"><label>Repairs: </label><input type="text" name="repairs" placeholder="Annual repairs"></div>
<div class="form-row"><label>Maintenance: </label><input type="text" name="maintenance" placeholder="Annual Maintenance"></div>
<div class="form-row"><label>Management Fees: </label><input type="text" name="management-fees" placeholder="Annual management fees"></div>
<div class="form-row"><label>CAM&nbsp;Charges: </label><input type="text" name="cam-charges" placeholder="Annual C.A.M. charges"></div>
<div class="form-row"><label>Other Expense #1: </label><input type="text" name="other-expense-1" placeholder="Annual other expense"></div>
<div class="form-row"><label>Other Expense #2: </label><input type="text" name="other-expense-1" placeholder="Annual other expense"></div>
<div class="form-row"><label>Other Expense #3: </label><input type="text" name="other-expense-1" placeholder="Annual other expense"></div>

<div class="section-head">Monthly Property Income</div>
<div class="form-row"><label>Tenant Type # 1: </label><input type="text" name="t-1" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-1-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 2: </label><input type="text" name="t-2" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-2-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 3: </label><input type="text" name="t-3" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-3-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 4: </label><input type="text" name="t-4" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-4-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 5: </label><input type="text" name="t-5" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-5-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 6: </label><input type="text" name="t-6" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-6-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 7: </label><input type="text" name="t-7" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-7-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 8: </label><input type="text" name="t-8" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-8-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 9: </label><input type="text" name="t-9" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-9-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 10: </label><input type="text" name="t-10" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-10-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 11: </label><input type="text" name="t-11" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-11-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 12: </label><input type="text" name="t-12" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-12-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 13: </label><input type="text" name="t-13" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-13-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 14: </label><input type="text" name="t-14" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-14-rent" placeholder="Tenant Monthly Rent"></div>
<div class="form-row"><label>Tenant Type # 15: </label><input type="text" name="t-15" placeholder="Tenant Name"></div>
<div class="form-row"><label>Monthly Rent: </label><input type="text" name="t-15-rent" placeholder="Tenant Monthly Rent"></div>
<!-- END PROPERTY INCOME AND EXPENSES PORTION-->
<div class="instructions"><label>Please enter Store Type Like &quot;Insurance Office&quot; or &quot;Nail Salon&quot; &nbsp;</label></div>
<div class="instructions"><label>Enter Apartments Like: Total Number of Rooms / Bedrooms / Bathrooms&nbsp; (4/1/1)</label></div>

<div class="form-row"><label>Notes / Comments: </label><textarea rows="6" name="notes-comments" placeholder="Please enter any information to help understand your request"></textarea></div>

<div class="form-row"><label>CAPTCHA: </label><input type="text" name="code" placeholder="CAPTCHA: 7+2 =" required></div>

<button type="submit" name="btnsubmit" class="form-control submit">SEND&nbsp;MESSAGE</button>

<!-- End Form -->
</form>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *