Contact form php | EmailFrom and Bcc not showing up. -


im kind of new php need bit of , have had no luck anywhere else.

i trying have person submits email sender, such when email comes through shows (unknown sender) or goes through server "testserver". want thier email address instead when unopened in inbox. client can click reply without having select email address.

i have had problems setting cc , bcc fields.

any ideas highly appreciated.

heres html

  <form  method="post" id="myform" name="myform">          <table width="250" border="0" cellspacing="0" cellpadding="0">            <tr>              <td>name:</td>              <td> <input type="text" name="name" id="name"></td>              </tr>            <tr>              <td>number:</td>              <td><input type="text" name="number" id="number"></td>              </tr>            <tr>              <td><label for="email">email:</label></td>              <td><input type="text" name="email" id="email"></td>              </tr>                                  <tr>              <td><label for="subject">subject:</label></td>              <td><input type="text" name="subject" id="subject" required></td>              </tr>                        <tr>              <td><label for="comment">comment:</label></td>              <td>&nbsp;</td>              </tr>                        <tr>              <td>&nbsp;</td>              <td><textarea name="comment" id="comment" cols="45" rows="5"></textarea></td>              </tr>                       <tr>              <td colspan="2">please answer question below</td>              </tr>                                    <tr>            <td> <?  if (isset($_post['qcchosenone']))  {        $captchaequations = array(                                0=>array('1 + 6',7),                                1=>array('8 - 3',5),                                2=>array('15 + 2',17),                                3=>array('8 + 2',10),                                4=>array('10 - 5',5),                           );         $qcchosen = $_post['qcchosenone'];       $qcgivenanswer = (int) trim($_post['qcquestion']);       $qcanswer = (int) $captchaequations[$qcchosen][1];       unset($_post['qcchosenone'],$_post['qcquestion']);	       if ($qcgivenanswer ==  $qcanswer)  	 include('contact.php');       else  	  print "<meta http-equiv=\"refresh\" content=\"0;url=error.php\">";    }   ?>   &#49;&#48;&#32;&#45;&#32;&#53;&#32;&#61;&#32; </td>             <td><input name="qcquestion" type="text" class="form_fields" id="captcha" />                                    <input type="hidden" name="qcchosenone" value="4" /></td>             </tr>            <tr>                       <td>&nbsp;</td>             <td><input type="submit" name="submit" id="submit" value="submit"></td>            </tr>          </table>         </form>             <script language="javascript" type="text/javascript">  var frmvalidator = new validator("myform");  frmvalidator.addvalidation("name","req","please enter name");  frmvalidator.addvalidation("tel","req","please enter telephone number");  frmvalidator.addvalidation("email","req","please enter email");  frmvalidator.addvalidation("email","email","please provide valid email address");  frmvalidator.addvalidation("city","req","please enter city");  frmvalidator.addvalidation("make","req","please enter make");  frmvalidator.addvalidation("model","req","please enter model");  frmvalidator.addvalidation("enquiry","req","please enter enquiry/comments");  frmvalidator.addvalidation("captcha","req","please enter answer simple calculation. ensure not spam crawler.");  </script>           

heres php

<?php    if ($_server["request_method"] == "post") {    $emailfrom = trim(stripslashes($_post['email']));   $emailto = "dalevanm@gmail.com";  $subject = "name, website enquiry form";  $name = trim(stripslashes($_post['name']));   $number = trim(stripslashes($_post['number']));   $email = trim(stripslashes($_post['email']));   $subject = trim(stripslashes($_post['subject']));   $comment = trim(stripslashes($_post['comment']));     // validation  $validationok=true;  if (!$validationok) {    print "<meta http-equiv=\"refresh\" content=\"0;url=error.htm\">";    exit;  }    // prepare email body text  $body = "";  $body .= "name: ";  $body .= $name;  $body .= "\n";  $body .= "number: ";  $body .= $number;  $body .= "\n";  $body .= "email: ";  $body .= $email;  $body .= "\n";  $body .= "subject: ";  $body .= $subject;  $body .= "\n";  $body .= "comment: ";  $body .= $comment;  $body .= "\n";     $headers .=  "\r\n".'cc: dalevanm@gmail.com' . "\r\n";      // send email   $success = mail($emailto, $subject, $body, $emailfrom, $header);    // redirect success page   if ($success){    print "<meta http-equiv=\"refresh\" content=\"0;url=_confirmation_enquiry.php\">";  }  else{    print "<meta http-equiv=\"refresh\" content=\"0;url=error.htm\">";  }  }  ?>

when send email:

$success = mail($emailto, $subject, $body, $emailfrom, $header); 

you've never defined variable called $header. almost defined 1 called $headers here:

$headers .=  "\r\n".'cc: dalevanm@gmail.com' . "\r\n"; 

but suspect may fail .= operator, since variable didn't exist. assign directly:

$headers =  "\r\n".'cc: dalevanm@gmail.com' . "\r\n"; 

and use variable:

$success = mail($emailto, $subject, $body, $emailfrom, $headers); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -