I have a template I downloaded and with it came a PHP form. When submitting the form the console shows: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
HTML:
<form action="contact-form.php" method="POST" class="contact-form">
<ul class="row">
<li class="col-md-6 form-item">
<label for="contact-name"><i class="ico-male"></i></label>
<input type="text" name="contact-name" class="contact-name" id="contact-name" value="Your Name" onblur="if(this.value=='')this.value='Your Name'" onfocus="if(this.value=='Your Name')this.value=''">
</li>
<li class="col-md-6 form-item">
<label for="contact-email"><i class="ico-email"></i></label>
<input type="email" name="contact-email" class="contact-email" id="contact-email" value="Your Email" onblur="if(this.value=='')this.value='Your Email'" onfocus="if(this.value=='Your Email')this.value=''">
</li>
<li class="col-md-12 form-item">
<label for="contact-message"><i class="ico-bubble"></i></label>
<textarea name="contact-message" class="contact-message" id="contact-message" data-placeholder="Your message"></textarea>
</li>
<li class="col-md-12 form-item">
<input type="submit" name="contact-btn" class="contact-btn general-link" id="contact-btn" value="Send Your Message">
</li>
</ul>
</form><!-- end of contact form -->
PHP:
<?php
if($_POST["submit"]) {
$fromEmail = strip_tags($_POST['contact-email']);
$fromName = strip_tags($_POST['contact-name']);
$themessage = strip_tags($_POST['contact-message']);
$themessage = $themessage."The Sender Is ( ".$fromName." )" ;
$toEmail = 'jh@gmail.com';
$toName = 'JH';
Mail::send('emails.contactus', $data , function($message) use ($toEmail, $toName, $fromEmail, $fromName, $subject)
{
$message->to($toEmail, $toName);
$message->from($fromEmail, $fromName);
$message->subject($subject);
});
$headers = 'From:' .$fromName . "\r\n" .
'Reply-To:' .$fromEmail. "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($toEmail, $subject, $themessage, $headers))
{
// Send
echo "success";
}
else{ echo "An error has be occured"; }
}
?>
I am doing this locally on IIS Server and receiving this.
Edit:
It is showing the error HTTP Error 500.0 - Internal Server Error C:\Program Files\PHP\v7.0\php-cgi.exe - The FastCGI process exited unexpectedly
I have gone through the fixes that are shown on other answers such as:
The FastCGI process exited unexpectedly
You might be using C:/[your-php-directory]/php.exe in Handler mapping of IIS just change it C:/[your-php-directory]/php-cgi.exe.
IIS 7.5 PHP failure "The FastCGI process exited unexpectedly"
To fix it I had to install the Visual C++ Redistributable for Visual Studio 2012 Update 3
It's still showing the same error. Not sure how to resolve this now.