为什么我的联系表单只有部分来自>

时间:2013-02-17 06:57:49

标签: php

我的联系表单似乎只发送部分信息。

我无法在设置的任何部分发现任何不同的内容,但系统既不会发送电话号码也不会发送手机号码。

在我的表格中我有

<form method="POST" name="contactform" action="changeofaddressfour.php"> 
<p>
<label for='name'>Your Name:</label> <br>
<input type="text" name="name">
 </p>
 <p>
<label for='email'>Email Address:</label> <br>
<input type="text" name="email"> <br>
 </p>
 <p>
 <label for='phone'>Telephone Number:</label> <br>
 <input type="text" name="phone"> <br>
</p>
 <p>
<label for='mobile'>Mobile Number:</label> <br>
<input type="text" name="mobile"> <br>
 </p>
 <p>
<label for='message'>New Address:</label> <br>
<textarea name="message"></textarea>
 </p>
<input type="submit" value="Submit"><br>
</form>

在另一页我有

  <?php
  $errors = '';
  $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here.
  if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
   $errors .= "\n Error: all fields are required";
    }
 $name = $_POST['name'];
 $email_address = $_POST['email'];
 $telephone_number = $_POST['phone'];
 $mobile_number = $_POST['mobile'];
   $message = $_POST['message'];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]        {2,3})$/i", $email_address)) {
   $errors .= "\n Error: Invalid email address";
 }
 if (empty($errors)) {
 $to = $myemail;
 $email_subject = "Change of Details: $name";
 $email_body = "You have received a new message. "."Here are the details:\n Name: $name      \n Email: $email_address \n Message \n $message";
$headers = "From: $myemail\n";
 $headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
 //redirect to the 'ackofdetails' page
 header('Location: ackofdetailsfour.php');
exit();
 }
echo nl2br($errors); ?>

1 个答案:

答案 0 :(得分:0)

更改 $email_body = "You have received a new message. "."Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message";

$email_body = "You have received a new message. "."Here are the details:\n Name: $name \n Email: $email_address \n Telephone Number: $telephone_number \n Mobile Number: $mobile_number \n Message \n $message";