php - Pass Query String variable into contact form email -


i have application form on page. working correctly except query string. want take url variable, , pass contact form email. ex. http://www.example.net?merchantid=12345

i want merchant id variable name , value display on email receive, along rest of user information. way sits breaks page. great send cc email without merchant id well.

here markup:

<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 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 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 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 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 email address." data-msg-email="please enter valid email address." maxlength="100" class="form-control" name="email" id="email">                                     </div>                                     <div class="col-md-6">                                         <label>confirm email address *</label>                                         <input type="email" value="" required data-msg-required="emails must match." data-msg-email="please enter 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"> agree <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 verification code." placeholder="type 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> 

here php:

<?php     session_start();  include("php/simple-php-captcha/simple-php-captcha.php"); include("php/php-mailer/class.phpmailer.php");   //  step 1 - enter email address below. $to = 'info@novawebdev.com';  $arrresult = array('response'=>'');  if(isset($_post['emailsent'])) {  $subject = 'rto camera application';  // step 2 - if don't want "captcha" verification, remove 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 fields list want receive on 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 $field) {         $message .= $field['text'].": " . htmlspecialchars($field['val'], ent_quotes) . "<br>\n";     }      $mail = new phpmailer;      $mail->issmtp();      // step 4 - if don't receive email, try configure parameters below:      //$mail->host = 'mail.yourserver.com';                // specify main , backup server     //$mail->smtpauth = true;                             // enable smtp authentication     //$mail->username = 'username';                       // smtp username     //$mail->password = 'secret';                         // smtp password     //$mail->smtpsecure = 'tls';                          // enable encryption, 'ssl' 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';  } } ?> 

i've been researching few hours, , how far i've come. i've never worked php outside basic copy paste contact form.

thanks!

you're there. in your

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

make sure $merchantid set parameter:

<input type="hidden" name="merchantid" value="<?php if ( isset( $_get['merchantid'] ) ) echo $_get['merchantid']; ?>" /> 

and it'll available as

$merchantid = $_post['merchantid']; 

in processing function.


Comments

  1. This is my last ACE class to work on my presentation. I will try my best to get as much as I can done. I was already lagging so much that I could not log in until I restarted and logged into the student account. I hate the lag on these Macs.
    vumoo

    ReplyDelete

Post a Comment

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -