嘿,我不能为我的生活弄清楚我在哪里出错了。表单提交时将其带到空白页面。没有错误或确认。只是空白。我假设这是一个语法错误,但我不能看到它出于某种原因。你们看到什么了吗? 这里是我的表单代码: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