Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从在线表单向客户发送报告,告知他选择的所有数据?_Php_Html - Fatal编程技术网

Php 从在线表单向客户发送报告,告知他选择的所有数据?

Php 从在线表单向客户发送报告,告知他选择的所有数据?,php,html,Php,Html,我是这个领域的新手 我已经为客户制作了一份销售一些产品的提交表 我将表单中的信息和客户输入的数据一起发送到电子邮件中。。 但我希望客户通过电子邮件获得相同的数据,并且根据客户在[email address:]字段中输入的电子邮件地址确定其需求的总价 我的PHP代码是: <?php if(isset($_POST['email'])) { $email_to = "HERE I PUT MY EMAIL"; $email_subject = "You've got a me

我是这个领域的新手 我已经为客户制作了一份销售一些产品的提交表 我将表单中的信息和客户输入的数据一起发送到电子邮件中。。 但我希望客户通过电子邮件获得相同的数据,并且根据客户在[email address:]字段中输入的电子邮件地址确定其需求的总价

我的PHP代码是:

<?php
if(isset($_POST['email'])) {

    $email_to = "HERE I PUT MY EMAIL";
    $email_subject = "You've got a message - Online Form";


    function died($error) {
        echo "We are very sorry, but ";
        echo $error."<br /><br />";
        die();
    }

    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['phone']) ||
        !isset($_POST['face_cream']) ||
        !isset($_POST['body_cream']) ||
        !isset($_POST['body_oil']) ||
        !isset($_POST['face_wash']) ||
        !isset($_POST['breast_oil']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }

    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $phone = $_POST['phone']; // required
    $face_cream = $_POST['face_cream']; // not required
    $body_cream = $_POST['body_cream']; // not required
    $body_oil = $_POST['body_oil']; // not required
    $face_wash = $_POST['face_wash']; // not required
    $breast_oil = $_POST['breast_oil']; // not required
    $comments = $_POST['comments']; // not required
    $agreement = $_POST['agreement']; // required

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
 if(strlen($phone) < 6) {
    $error_message .= 'The Phone Number you entered do not appear to be valid.<br />';
  }
 if(strlen($agreement) < yes) {
    $error_message .= 'The agreement you entered do not appear to be valid.<br />';
  }
if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Phone Number: ".clean_string($phone)."\n";
    $email_message .= "The chosen quantity of (Face Cream) is: ".clean_string($face_cream)."\n";
    $email_message .= "The chosen quantity of (Body Cream) is: ".clean_string($body_cream)."\n";
    $email_message .= "The chosen quantity of (Body Oil) is: ".clean_string($body_oil)."\n";
    $email_message .= "The chosen quantity of (Face Wash) is: ".clean_string($face_wash)."\n";
    $email_message .= "The chosen quantity of (Breast Oil) is: ".clean_string($breast_oil)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";



// checkbox
if(isset($_POST['agreement']) &&
   $_POST['agreement'] == 'yes')
{
    echo "You've accepted our terms and conditions.<br>";
}
else
{
    echo "You didn't agree on the Terms & Conditions.<br>";
}   



// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>

您只需要另一个@mail命令,将电子邮件从和发送到反向

...... all your d**kload of code
@mail($email_to, $email_subject, $email_message, $headers);  // Sends to YOU
@mail($email_from, $email_subject, $email_message, $headers); // Sends to the client
关于你未来的问题:

  • 这些代码都不是你写的(如果是的话,你应该知道该怎么做)
  • 您复制了整个代码,因为(请参见问题1)
  • 你没有清楚地解释问题是什么

  • 现在。如果这是你想要的。请单击“接受答案”勾选以帮助建立良好的因果报应

    我希望您将问题总结为3行。您还应该用复选框复选框替换以“如果(strlen($agreement)