javascript - send form data to admin email in codeIgniter -


i newer codeigniter. have 1 contact form fields of stream, name, email, contact. have problem form data not send admin email. when tried submit data on contact form page source alert have given other alert data. have tried following code,

$('#interiorid').submit(function (e) {          e.preventdefault();         var interiorstream = $('#interiorstream').val();          var interiorname = $('#interiorname').val();           var interiormobile = $('#interiormobile').val();          var interioremail = $('#interioremail').val();          var mobilevarify = /[0-9]/.test(interiormobile);          var regex = /^([a-za-z0-9_.+-])+\@(([a-za-z0-9-])+\.)+([a-za-z0-9]{2,4})+$/;    var datastring = 'interiorstream =' +  interiorstream + '&interiorname =' + interiorname + '&interiormobile =' + interiormobile + '&interioremail =' + interioremail;       alert(interiorstream);          if (interiorstream == "0") {              alert('please select stream');          }          else {              if (interiorname.length > 2) {                  if (mobilevarify == true && interiormobile.length == 10) {                      if (regex.test(interioremail) == true) {                          $.ajax({                               url: 'interior_email',                              type: 'post',                             data: datastring,                              success: function (msg, status) {    alert(status);    alert(msg);                                  $("#interiorid")[0].reset();                                  window.location.href = "/contact/thank-you";                              }                          });                      }                      else {                          alert('invalid email');                      }                  }                  else {                      alert('invalid number');                  }              }              else {                  alert('please enter name');              }          }      });
<!--- view ---->  <form id="interiorid">                                  <div class="form-div">                                      <select value="" id="interiorstream" >                                          <option value="0">select stream</option>                                          <option value="interior designing">interior designing</option>                                          <option value="fashion designing">fashion designing</option>                                        </select>                                  </div>                                  <div class="form-div">                                      <input type="text" placeholder="name" id="interiorname">                                  </div>                                  <div class="form-div">                                      <input type="text" placeholder="phone" id="interiormobile">                                  </div>                                  <div class="form-div">                                      <input type="text" placeholder="email" id="interioremail">                                  </div>                                  <div class="form-div">                                      <input type="submit" value="submit">                                  </div>                              </form>    <!----controller ---->    <?php    class home extends ci_controller {        function __construct() {          parent::__construct();          $this->load->helper('url');          $this->load->library('email');          $this->load->helper(array('url'));         }        function index() {            $this->load->view('templates/header');          $this->load->view('home');          $this->load->view('templates/footer');          $this->load->helper('form');            $this->load->view('interior/interior-intro');       }               function interior_email()  {    if (!isset($_post['e-mail'])){        //redirect if no parameter e-mail        redirect(base_url());      }else{          $interiorstream = $this->input->post('interiorstream');          $interiorname = $this->input->post('interiorname');          $interiorphone = $this->input->post('interiorphone');          $interioremail = $this->input->post('interioremail');            $message = 'hello admin, mail received interior design page contact form.<br/><br/>                  stream:' . $interiorstream . '<br/><br/>                  name :' . $interiorname . '<br/><br/>                  contact :' . $interiorphone . '<br><br>  		email :' . $interioremail;                      $headers1 = "mime-version: 1.0\r\n";          $headers1 .= "content-type: text/html; charset=iso-8859-1\r\n";          $headers1 .= "to:";          $headers1 .= "example.com <info@example.com>";          $headers1 .= "\r\n";          $headers1 .= 'from: inifd : info@example.com' . "\r\n";          $headers1 .= "\r\n";          $subject = "enquiry example.com web";          $email = 'admin@example.com';                   if (mail($email, $subject, $message, $headers1)) {           echo 'mail has been sent';              } else {                  echo 'mail sending failed';              }   }        }    }  ?>

wrong popup this:

enter image description here

so please me.

  1. if running on localhost, near impossible send emails. can check if want send check post out or try phpmailer

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -