Passing select value from a form through php and then out to email -
i trying add form came bootstrap html template. specifically, add select option can't seem passed through php , out email. attach html , php code below.
<select id="selectbasic" name="selectbasic" class="form-control "> <option value="zombie">zombie volunteer</option> <option value="sponsor">sponsorship</option> </select>
what need have in php file pick value?
i tried this...
$body = "below details submitted user on website. <br><br> inquiry type: ".$_post['selectbasic']." <br><br> name: ".$_post['name']." <br><br> email: ".$_post['email']." <br><br> business/organization: ".$_post['phone']." <br><br> comment: ".$_post['comment']."";
any appreciated. in advance!
here's complete form:
<header class="clearfix"> <a href="#" title="register event" class="btn register-trigger"><i class="fa fa-plus-circle"></i>submit inquiry</a> <form id="register" method="post" action="form/register.php"> <div class="field-wrapper"> <h3 class="regheading">zombie<span> signup</span></h3> <div class="row"> <div class="form-group"> <label class="col-md-3 control-label" for="selectbasic">inquiry type</label> <div class="col-md-6"> <select id="selectbasic" name="selectbasic" class="form-control "> <option value="zombie">zombie volunteer</option> <option value="sponsor">sponsorship</option> </select> </div> </div> <br><br> <div class="col-md-4 form-row"> <input type="text" class="form-control" id="name" name="name" placeholder="full name" /> </div> <div class="col-md-4 form-row"> <input type="tel" class="form-control" id="phone" name="phone" placeholder="business/organization" /> </div> <div class="col-md-4 form-row"> <input type="email" class="form-control" id="email" name="email" placeholder="email" /> </div> </div> <div class="form-row clearfix"> <textarea cols="60" rows="3" id="comment" name="comment" class="form-control" placeholder="please leave details pertaining inquiry..."></textarea> </div> <input type="submit" value="submit" class="btn btn-custom btn-lg" id="submit" name="submit" /> </div> </form> </header>
here's complete php (obviously i've changed email address):
<?php ///////////////// editable options ///////////////////// $receiving_email_address = "myemail@domain.com"; // set email address here want receive emails $receiving_email_address_name = "kristen"; // add name associated email address above. $custom_subject = "zombie raceinquiry"; // change subject line of email per choice. // ============================= not edit below line ====================================== if ((isset($_post['name'])) && (strlen(trim($_post['name'])) > 0)) { $name = stripslashes(strip_tags($_post['name'])); } else {$name = 'no name entered';} if ((isset($_post['phone'])) && (strlen(trim($_post['phone'])) > 0)) { $phone = stripslashes(strip_tags($_post['phone'])); } else {$phone = 'no phone entered';} if ((isset($_post['email'])) && (strlen(trim($_post['email'])) > 0)) { $email = stripslashes(strip_tags($_post['email'])); } else {$email = 'no email entered';} if ((isset($_post['comment'])) && (strlen(trim($_post['comment'])) > 0)) { $comment = stripslashes(strip_tags($_post['comment'])); } else {$phone = 'no phone entered';} ob_start(); // email building $to = $receiving_email_address; $email = $_post['email']; $fromaddress = $_post['email']; $fromname = $_post['name']; $body = "below details submitted user on website.<br><br>inquiry type: ".$_post['selectbasic']."<br><br>name: ".$_post['name']."<br><br>email: ".$_post['email']."<br><br>business/organization: ".$_post['phone']." <br><br>comment: ".$_post['comment'].""; require("phpmailer.php"); $mail = new phpmailer(); $mail->from = "$email"; $mail->fromname = "$fromname"; $mail->addaddress("$receiving_email_address","$receiving_email_address_name"); $mail->ishtml(true); $mail->subject = "$custom_subject"; $mail->body = $body; $mail->altbody = "this text-only body"; if(!$mail->send()) { $recipient = '$receiving_email_address'; $subject = 'contact form failed'; $content = $body; // send mail mail($recipient, $subject, $content, "from: $receiving_email_address\r\nreply-to: $email\r\nx-mailer: dt_formmail"); exit; } ?>
Comments
Post a Comment