Php 为什么我的联系方式只有一部分通过>;

Php 为什么我的联系方式只有一部分通过>;,php,Php,我的联系方式似乎只发送了部分信息 在设置的任何部分我都看不出有什么不同,但系统既不发送电话号码也不发送手机号码 以我的形式,我有 您的姓名: 电子邮件地址: 电话号码: 手机号码: 新地址: 在另一页我有 <?php $errors = ''; $myemail = 'antonylambert@c5d.co.uk';//<-----Put Your email address here. if(empty($_POST['name'

我的联系方式似乎只发送了部分信息

在设置的任何部分我都看不出有什么不同,但系统既不发送电话号码也不发送手机号码

以我的形式,我有


您的姓名:

电子邮件地址:

电话号码:

手机号码:

新地址:



在另一页我有

  <?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); ?>

更改
$email\u body=“您收到了一封新邮件。”“以下是详细信息:\n Name:$Name\n email:$email\u address\n message\n$message”


$email\u body=“您收到了新邮件。”“以下是详细信息:\n Name:$Name\n email:$email\u地址\n电话号码:$Telephone\u Number\n Mobile Number:$Mobile\u Number\n message\n$message”

您没有将变量
$telephone\u number
$mobile\u number
包含在您的
$email\u body
中,因此它们不会显示在电子邮件中。您的代码没有问题,这也是您可能无法获取这些变量的唯一原因,因为这些变量没有在body中使用。您的意思是这样吗$email_subject=“更改详情:$name”$email\u body=“您收到了一封新邮件。”。“以下是详细信息:\n Name:$Name\n email:$email\u address\n phone:$telephone\u number\n mobile:$mobile\u number\n message\n$message”;非常感谢。太好了。我在谷歌上搜索了几个小时,想找到这个。
  <?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); ?>