PHP表单发送空白电子邮件


PHP form sending blank email

我已经创建了一个php,用于将我的消息从网站发送到客户的电子邮件。但一旦发送了电子邮件,我就会收到一封空白的电子邮件。我试过使用$_张贴[姓名]。打电话给现场,我试过了。name。

我正在使用引导程序来构建表单。

<form class="email" method="post" action="mailer.php">
              <div class="form-group col-md-6">
                <label for="name">Full Name</label>
                <input type="text" class="form-control" id="name" name="name" placeholder="Enter Your Full Name">
              </div>
              <div class="form-group col-md-6">
                <label for="telephone">Telephone</label>
                <input type="text" class="form-control" id="telephone" name="telephone" placeholder="Enter Your Telephone Number">
              </div>
              <div class="form-group col-md-6">
                <label for="postcode">Post Code</label>
                <input type="text" class="form-control" id="postcode" name="postcode" placeholder="Postcode">
              </div>
              <div class="form-group col-md-6">
                <label for="email">Email</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="Enter Your Email">
              </div>
              <div class="form-group col-md-6">
                <label for="laptopmake">Make</label>
                <input type="text" class="form-control" id="laptopmake" name="laptopmake" placeholder="Enter Your Laptop Make(HP,Toshiba">
              </div>
              <div class="form-group col-md-6">
                <label for="laptopmodel">Model</label>
                <input type="text" class="form-control" id="laptopmodel" name="laptopmodel" placeholder="Enter Your Laptop Model Number">
              </div>
              <div class="form-group col-md-12">
                <label for="faultdescription">Fault Description</label>
                  <textarea class="form-control" rows="4" id="faultdescription" name="faultdescription" placeholder="Describe Your Laptop Fault"></textarea>
              </div>
              <div class="form-group col-md-6">
                <button type="submit" class="btn btn-warning">
                      Send Message
                </button>
               </div>
        </form>

这是PHP邮件。

   <?php
error_reporting(E_ALL); ini_set('display_errors', 1);
print_r($_POST)
    $name = $_POST['name'];
    $telephone = $_POST['telephone'];
    $email = $_POST['email'];
    $postcode = $_POST['postcode'];
    $laptopmake = $_POST['laptopmake'];
    $laptopmodel = $_POST['laptopmodel'];
    $faultdescription = $_POST ['faultdescription'];
    $message =$_POST['message'];

     $to = "aihsanm93@gmail.com";
    $subject="Laptop Repair Request!"; 
   $body = 'Name:' .$name. "'n'n"; 'Email:' .$email. "'n'n" ;'Postcode:'  .$postcode. "'n'n"; 'Message:' .$message . "'n'n";'Telephone:' .$telephone. "'n'n"; 'Laptop Make:' .$laptopmake. "'n'n"; 'Laptop Model:' .$laptopmodel. "'n'n";  'Fault Description:' .$faultdescription. "'n'n"; mail($to, $subject,$body, $from); 
    echo "Your Message has been sent"; 

    header('Location: index.html');
exit();

/* Functions we used */
function check_input($data, $problem=''){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
};
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>

更新版本

使用"."而不是";"来收集信息。将以"$body"开头的行更改为:

 $body = 'Name:' .$name. "'n'n" . 'Email:' .$email. "'n'n" . 'Postcode:'  .$postcode. "'n'n".  'Message:' .$message . "'n'n" . 'Telephone:' .$telephone. "'n'n" . 'Laptop Make:' .$laptopmake. "'n'n" . 'Laptop Model:' .$laptopmodel. "'n'n" .  'Fault Description:' .$faultdescription. "'n'n";
 mail($to, $subject,$body, $email);