嘿,我不能爲我的生活弄清楚我在哪裏出錯了。表單提交時將其帶到空白頁面。沒有錯誤或確認。只是空白。我假設這是一個語法錯誤,但我不能看到它出於某種原因。你們看到什麼了嗎? 這裏是我的表單代碼:php mail()腳本不工作
<form method="POST" action="mailtest.php">
<label>Name<span class="req">*</span></label>
<input name="name" placeholder="Type Here">
<label>Email<span class="req">*</span></label>
<input name="email" type="email" placeholder="Type Here">
<label>Subject</label>
<input name="subjectf" placeholder="Type Here">
<label>Message<span class="req">*</span></label>
<textarea name="message" placeholder="Type Here"></textarea>
<input class="submit" name="submit" type="submit" value="">
<span class="right" style="color:red">* represents a mandatory field.</span>
</form>
,這裏是PHP腳本我有mailtest.php頁:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = $_POST['name'];
$to = '[email protected]';
$subject= 'new enquiry on website';
$subjectf= $_POST['subjectf'];
$body = "From: $name\n E-Mail: $email\n Subject: $subjectf\n Message:\n $message";
if ($_POST['submit']) {
if ($name != '' && $email != '' && $message != '') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else {
echo '<p>You need to fill in all required fields!!</p>';
}
}
?>
isset($ _ POST [ '提交']) 可能會幫助:) – 2013-05-02 02:28:39
郵件是一個棘手的事情來調試,你是否收到任何錯誤信息? – 2013-05-02 02:28:45
根本沒有錯誤信息。只是一個空白頁面。我剛剛嘗試了「isset($ _ POST ['submit'])」,它給了我這個錯誤「解析錯誤:語法錯誤,意想不到'{'在11行中的/home/a2375440/public_html/mailtest.php錯誤:語法錯誤,意想不到''在第11行的/home/a2375440/public_html/mailtest.php中。第11行是我剛剛插入的那行 – user2291730 2013-05-02 02:32:16