我有一个我下载的模板,随之来了一个PHP表单。提交表单时,控制台显示:无法加载资源:服务器响应状态为500(内部服务器错误)
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"; }
}
?>
我在IIS服务器上本地执行此操作并接收此信息。
编辑:
显示错误HTTP错误500.0 - 内部服务器错误 C:\ Program Files \ PHP \ v7.0 \ php-cgi.exe - FastCGI进程意外退出
我已经完成了其他答案中显示的修复程序,例如:
The FastCGI process exited unexpectedly
您可能在IIS的Handler映射中使用C:/ [your-php-directory] /php.exe只需将其更改为C:/ [your-php-directory] /php-cgi.exe。
IIS 7.5 PHP failure "The FastCGI process exited unexpectedly"
要修复它,我必须安装Visual C ++ Redistributable for Visual Studio 2012 Update 3
它仍然显示相同的错误。现在不知道如何解决这个问题。
答案 0 :(得分:0)
检查表单部分的编码。