PHP sendmail, values not passing through to email -


i have contact form on html page using php script on seperate php page send text values entered input boxes in email

everything working except text entered in forms input boxes not passing through, blank

below doing:

html

    <form class="form-inline" action="mail_handler.php" method="post"         enctype="multipart/form-data">                 <div class="fullwidth">                   <div class="left-feild col-md-6">                     <div class="form-group">                       <input type="text" class="form-control color01 background13 border-color08" name="name" placeholder="name" required>                     </div>                     <div class="form-group">                       <input type="email" class="form-control color01 background13 border-color08" name="email" placeholder="email" required>                     </div>                     <div class="form-group">                       <input type="text" class="form-control color01 background13 border-color08" name="number" placeholder="phone/cellphone number">                     </div>                     <div class="form-group">                       <input type="text" class="form-control color01 background13 border-color08" name="company" placeholder="company name">                     </div>                   </div>                   <div class="right-feild col-md-6">                     <div class="form-group fullwidth">                       <textarea class="form-control color01 background13 border-color08" rows="3" placeholder="type message here" name="message" required></textarea>                     </div>                   </div>                 </div>                 <div class="submitbutton fullwidth">                   <button type="submit" value="submit" name="submit" class="btn more background07 color01 color01-hover01" >book</button>                 </div>               </form> 

php

<?php  $name = $_post['name']; $number = $_post['number']; $email = $_post['email']; $company = $_post['company']; $message = $_post['message'];  $from = 'from: info@recipient.com';  $to = 'myemail@gmail.com'; //email $subject = 'website booking enquiry'; $message = "from: $name\n number: $number\n e-mail: $email\n company:     $company\n message: $message\n ";  $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: text/html\r\n"; $headers = 'from: info@recipient.com' . "\r\n" . 'reply-to: $email' . "\r\n" . 'x-mailer: php/' . phpversion();  mail($to, $subject, $message, $headers); header( "location: index.html" );//if u wish redirected ?> 

this getting long comments, therefore have submitted following.

you have quite few errors in code.

you've missed concatenate/dot last header , "breaking chain" were, , variables don't parsed in single quotes

also first header should not have leading dot.

$name = $_post['name']; $number = $_post['number']; $email = $_post['email']; $company = $_post['company']; $message = $_post['message'];  $from = 'from: info@recipient.com';  $to = 'myemail@gmail.com'; //email $subject = 'website booking enquiry'; $message = "from: $name\n number: $number\n e-mail: $email\n company:     $company\n message: $message\n ";  $headers  = "mime-version: 1.0\r\n"; $headers .= "content-type: text/html\r\n"; $headers .= 'from: info@recipient.com' . "\r\n" . "reply-to: $email" . "\r\n" . 'x-mailer: php/' . phpversion();  mail($to, $subject, $message, $headers); header( "location: index.html" );//if u wish redirected exit; 

you should check empty fields, because can submit nothing filled , empty results.

i.e.:

if(!empty($_post['name']) || !empty($_post['email'])) {  // assign variables post arrays , process mail  $name = $_post['name']; $number = $_post['number']; $email = $_post['email']; $company = $_post['company']; $message = $_post['message'];  // ... rest of code  } 

note: || means "or". can use that, or && means "and", or mix of both.


footnotes:

\n not show data on separate lines, should goal, since using html headers.

you need use <br> if want here.

consult manual on mail:

a few other alternatives php's mail(), phpmailer , swiftmailer:


as stated in comments:

enctype="multipart/form-data" - remove form element. – cbroe"

that can safely removed since you're not dealing files.

if server issue, need find out problem , beyond scope of question.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -