php有效,但没有显示内容

时间:2016-06-14 23:00:06

标签: php html forms email

我正在处理表单,我不得不使用php通过电子邮件发送数据。我真的很喜欢编码。我刚开始使用php。我的表单工作,我甚至通过它接收电子邮件,但PHP页面显示空白。我尝试使用echo和错误报告,但没有显示任何html代码也显示出来。这可能是一个新手的错误。我的PHP代码:

    <?php
$name = $_POST['fullName'];
$email_address = $_POST['email'];
$phone = $_POST['phoneNumber'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$age = $_POST['age'];


$headers = "From: noreply@domainname.com";
$to = 'someone@example.com'; 
$email_subject = "Website Contact Form:  $name";
$email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\ngender: $gender\n\ncountry: $country\n\nage: $age";

mail($to,$email_subject,$email_body,$headers);
return true;

echo "thank you"
?>

1 个答案:

答案 0 :(得分:2)

您现在有两种选择:

  1. 删除return true;
  2. echo "thank you";
  3. 之前移动return true;

    您可以在此处阅读有关返回的更多信息: http://php.net/manual/en/function.return.php

    旁注:你在回声之后忘记了一个分号(;):

    echo "thank you";
    //--------------^
    
相关问题