0
我無法在代碼中找到錯誤。我的PHP代碼位於我的index.html文件中。我無法從我的靜態網頁發送消息。我無法使用郵件發送郵件()PHP函數
HTML代碼:
<div class="col-md-6">
<form action="index.html" method="POST" class="contact-form" role="form">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Your Full Name">
<input type="email" class="form-control" id="email" name="email" placeholder="Your E-mail">
<input type="text" class="form-control" id="subj" name="subj" placeholder="Your Subject">
<textarea id="mssg" name="mssg" placeholder="Your Message" class="form-control" rows="10"></textarea>
<input class="btn btn-main btn-lg" type="submit" id="submit" name="submit" data-loading-text="<i class='fa fa-spinner fa-spin'></i> Sending...">
</form>
</div>
PHP代碼:
<?php
if (isset($_POST['submit'])) {
$to = '[email protected]';
$siteName = 'http://www.website.com';
$name = $_POST['fname'];
$mail = $_POST['email'];
$subject = $_POST['subj'];
$message = $_POST['mssg'];
$mailSub = '[Contact] [' . $siteName . '] '.$subject;
$body = 'Sender Name: ' . $name . "\n\n";
$body .= 'Sender Mail: ' . $mail . "\n\n";
$body .= 'Message Subject: ' . $subject . "\n\n";
$body .= 'Message: ' . $message;
$header = 'From: ' . $mail . "\r\n";
$header .= 'To: ' . $to . "\r\n";
mail($to, $mailSub, $body, $header);
}else{
echo '0';
}
?>
我收到一個錯誤每次我嘗試通過我的網站發送消息的時間。謝謝!
「我每次嘗試通過我的網站發送郵件時都收到錯誤」什麼錯誤? – 2016-08-15 03:27:18
'action =「index.html」'您是否指示您的系統將'.html'文件作爲PHP處理?如果不是,那麼*「休斯頓,我們有問題」*。 –