Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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 - Fatal编程技术网

Php 将查询字符串变量传递到联系人表单电子邮件中

Php 将查询字符串变量传递到联系人表单电子邮件中,php,Php,我的页面上有一张申请表。除查询字符串外,所有内容都正常工作。我想获取一个带有变量的url,并将其传递到联系人表单电子邮件中。前 我希望商户id变量名称和值与其他用户信息一起显示在我收到的电子邮件上。它现在的位置打破了我的页面。这将是伟大的发送抄送电子邮件没有这个商人id以及 这是我的标记: <form id="shortApplication" action="{site_url}application#contact-sent" method="POST" enctype="multip

我的页面上有一张申请表。除查询字符串外,所有内容都正常工作。我想获取一个带有变量的url,并将其传递到联系人表单电子邮件中。前

我希望商户id变量名称和值与其他用户信息一起显示在我收到的电子邮件上。它现在的位置打破了我的页面。这将是伟大的发送抄送电子邮件没有这个商人id以及

这是我的标记:

<form id="shortApplication" action="{site_url}application#contact-sent" method="POST" enctype="multipart/form-data" data-type="advanced">
    <input type="hidden" value="true" name="emailSent" id="emailSent">
                            <input type="hidden" name="XID" value="{XID_HASH}" />                               
                            <input type="hidden" name="merchantid" value='<?php echo $merchantid; ?>' />                                
                            <div class="row">
                                <div class="form-group">
                                    <div class="col-md-6">
                                        <label>Your First Name *</label>
                                        <input type="text" value="" required data-msg-required="Please enter your first name." maxlength="100" class="form-control" name="first_name" id="first_name">
                                    </div>
                                    <div class="col-md-6">
                                        <label>Your Last Name *</label>
                                        <input type="text" value="" required data-msg-required="Please enter your last name." maxlength="100" class="form-control" name="last_name" id="last_name">
                                    </div>                                      
                                </div>
                            </div>  
                            <div class="row">
                                <div class="form-group">
                                    <div class="col-md-6">
                                        <label>Your Business Name *</label>
                                        <input type="text" value="" required data-msg-required="Please enter your business name." maxlength="100" class="form-control" name="business_name" id="business_name">
                                    </div>
                                    <div class="col-md-6">
                                        <label>Your Phone Number *</label>
                                        <input type="text" value="" required data-msg-required="Please enter your phone number." maxlength="100" class="form-control" name="phone" id="phone">
                                    </div>                                      
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <div class="col-md-6">
                                        <label>Your email address *</label>
                                        <input type="email" value="" required data-msg-required="Please enter your email address." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email" id="email">
                                    </div>
                                    <div class="col-md-6">
                                        <label>Confirm Your email address *</label>
                                        <input type="email" value="" required data-msg-required="Emails must match." data-msg-email="Please enter a valid email address." maxlength="100" class="form-control required email" equalTo='#email' name="emailConfirm" id="emailConfirm">
                                    </div>
                                </div>
                            </div>                                  
                            <div class="row">
                                <div class="checkbox">
                                    <div class="form-group">
                                        <div class="col-md-6">
                                            <label>
                                                <input type="checkbox" id="checked"> I agree to the <a href="{site_url}terms-and-conditions" target="_blank">terms & conditions</a>
                                            </label>
                                        </div>                                      
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <label>Human Verification *</label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <div class="captcha form-control">
                                            <div class="captcha-image">
                                                <?php
                                                $_SESSION['captcha'] = simple_php_captcha(array(
                                                    'min_length' => 6,
                                                    'max_length' => 6,
                                                    'min_font_size' => 22,
                                                    'max_font_size' => 22,
                                                    'angle_max' => 3
                                                ));

                                                $_SESSION['captchaCode'] = $_SESSION['captcha']['code'];

                                                echo '<img src="' . "php/simple-php-captcha/simple-php-captcha.php/" . $_SESSION['captcha']['image_src'] . '" alt="CAPTCHA code">';
                                                ?>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-8">
                                        <input type="text" value="" maxlength="6" data-msg-captcha="Wrong verification code." data-msg-required="Please enter the verification code." placeholder="Type the verification code." class="form-control" name="captcha" id="captcha">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <hr>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <input type="submit" id="shortApplicationSubmit" value="Send Message" class="btn btn-primary btn-lg pull-right" data-loading-text="Loading..." disabled="disabled">
                                </div>
                            </div>
                        </form>


以下是我的PHP:

<?php
    session_start();

include("php/simple-php-captcha/simple-php-captcha.php");
include("php/php-mailer/class.phpmailer.php");


//  Step 1 - Enter your email address below.
$to = 'info@novawebdev.com';

$arrResult = array('response'=>'');

if(isset($_POST['emailSent'])) {

$subject = 'RTO Camera Application';

// Step 2 - If you don't want a "captcha" verification, remove that IF.
if (strtolower($_POST["captcha"]) == strtolower($_SESSION['captcha']['code'])) {

    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $business_name = $_POST['business_name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $merchantid = $_GET['merchantid'];
    // $emailConfirm = $_POST['emailConfirm'];

    // Step 3 - Configure the fields list that you want to receive on the email.
    $fields = array(
        0 => array(
            'text' => 'First Name',
            'val' => $_POST['first_name']
        ),
        1 => array(
            'text' => 'Last Name',
            'val' => $_POST['last_name']
        ),
        2 => array(
            'text' => 'Business Name',
            'val' => $_POST['business_name']
        ),
        3 => array(
            'text' => 'Phone Number',
            'val' => $_POST['phone']
        ),
        4 => array(
            'text' => 'Email',
            'val' => $_POST['email']
        ),
        5 => array(
            'text' => 'Merchant ID',
            'val' => $_POST['merchantid']
        )
    );

    $message = "";

    foreach($fields as $field) {
        $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
    }

    $mail = new PHPMailer;

    $mail->IsSMTP();

    // Step 4 - If you don't receive the email, try to configure the parameters below:

    //$mail->Host = 'mail.yourserver.com';                // Specify main and backup server
    //$mail->SMTPAuth = true;                             // Enable SMTP authentication
    //$mail->Username = 'username';                       // SMTP username
    //$mail->Password = 'secret';                         // SMTP password
    //$mail->SMTPSecure = 'tls';                          // Enable encryption, 'ssl' also accepted

    $mail->From = $email;
    $mail->FromName = $_POST['first_name'].' '.$_POST['last_name'];
    $mail->AddAddress($to);
    $mail->AddReplyTo($email, $first_name, $last_name);
    $mail->AddCC($email);
    $mail->IsHTML(true);

    $mail->CharSet = 'UTF-8';

    $mail->Subject = $subject;
    $mail->Body    = $message;  

    if($mail->Send()) {
       $arrResult['response'] = 'success';
    } else {
        $arrResult['response'] = 'error';
    }

} else {

    $arrResult['response'] = 'captchaError';

}
}
?>

我已经研究了几个小时,这就是我所取得的成就。除了联系人表单的基本复制粘贴之外,我从未使用过PHP


谢谢

你就快到了。在你的

<input type="hidden" name="merchantid" value='<?php echo $merchantid; ?>' />

在您的处理函数中。

我粘贴了以前使用过的相同代码,它会打断我的页面。说明:遇到PHP错误严重性:注意消息:未定义索引:merchantid文件名:libraries/Functions.PHP(688):eval()'d代码行号:153第153行是带有隐藏PHP get的行如果在url中加载带有get参数的页面,它是否也会断开?在任何情况下,都应该有一个isset()检查。见编辑后的答案。要验证是否正在将变量放入表单中,请在源代码中查看它。我收到一个意外错误“isset”,我的页面已完全断开。很抱歉,这次忘记在if条件周围添加括号。好的,现在在第25行显示错误,即:$merchantid=$\u get['merchantid'];我是否只需要在输入中输入$merchantid?
<input type="hidden" name="merchantid" value="<?php if ( isset( $_GET['merchantid'] ) ) echo $_GET['merchantid']; ?>" />
$merchantid = $_POST['merchantid'];