2014-04-29 223 views
0

我对PHP很陌生,无法找出如何解决问题。我查看了许多其他类似问题的问题,但我无法获得他们在我的代码中使用的解决方案。PHP表单提交后空白白

当您在下一页上提交表单时,电子邮件会按照原样发送,但页面会变成白色。我已将其更改为目标_blank,因此它会生成一个新的标签,但它仍然令人困惑。

的网页是:http://designbycrisscross.com/contact.html

而这里的contact.php的内容:

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$budget = $_POST['budget']; 
$message = $_POST['message']; 
$human = $_POST['human']; 

$to = '[email protected]'; 
$subject = 'New Email from CrissCross Website'; 
$from = $email; 

$body = "From: $name\n E-Mail: $email\n Budget: $budget\n Message:\n $message"; 

mail ($to, $subject, $body, $from); 
if ($_POST['submit'] && $human == '4') { 

if (mail ($to, $subject, $body, $from)) { 
echo 'Your message has been sent!'; 
} else { 
echo '<p>Something went wrong, go back and try again!</p>'; 
} 

} else if ($_POST['submit'] && $human != '4') { 
echo '<p>You answered the anti-spam question incorrectly!</p>'; 
} 
?> 
+1

随着一个非常艰难的“C”,代码。展示下。这不像我们可以通过访问您的页面来查看您的实际PHP“源代码”。 PHP只是一种奇怪的动物。 –

+0

如果您不发布PHP代码,我们无法提供帮助。 – Beardminator

+0

最有可能:您没有编写任何PHP(您发送邮件后)输出要显示的HTML文档而不是普通的白页。 – Quentin

回答

0

如果邮件被发送,那么唯一可能的解释是,$ _ POST [“提交” ] == false(不太可能)或$ human!='4'(更可能)。

推理:邮件($ to,$ subject,$ body,$ from)在第14行运行,但它不会超过第15行的条件。如果要使它超过第15行的条件,它必须输出至少一些东西。

0

尝试重写您的条件以提供更多信息。

if ($_POST['submit']) { 
    if ($human == '4') { 
     if (mail($to, $subject, $body, $from)) { 
      echo 'Your message has been sent!'; 
     } else { 
      echo '<p>Something went wrong, go back and try again!</p>'; 
     } 
    } else { 
     echo '<p>You answered the anti-spam question incorrectly!</p>'; 
    } 
} else { 
    trigger_error('Form submission not detected!', E_USER_ERROR); 
} 
+0

哦,我明白发生了什么事。谢谢。我会看看这是否修复它。 – neena