PHP & HTML Mailer Only Sending One Parameter in the Body -
this first time posting here, please excuse me if don't use code formatting correctly. also, php not strong-point.
i'm attempting send user-populated e-mail html , php. i've gotten e-mail send, i'm having issues body of e-mail. phone number populating e-mail, nothing else, not name, email, or message. ideas?
i know parameters being populated. inspect page, , watch network events through firebug on firefox. parameters being passed php, i'm certain.
//building message body $name = $_post['name']; $email = $_post['email']; $phone = $_post['phone']; $message = $_post['message']; //adding body variable $body = "name: " + $name + "\r\n" + "e-mail: " + $email + "\r\n" + "phone: " + $phone + "\r\n" + "message: " + $message + "\r\n"; //email info $to = 'thisisafake@gmail.com'; $subject = 'you have been contacted via web form!'; $from = 'admin@vancouverbolt.com'; mail($to, $subject, $body);
<!-- mailer --> <form role="form" method="post" action="mail/contact_me.php"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <input type="text" data-validation-required-message="please enter name." required="" id="name" name="name" placeholder="your name *" class="form-control" value=""> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input type="email" data-validation-required-message="please enter email address." required="" id="email" name="email" placeholder="your email *" class="form-control" value=""> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input type="tel" data-validation-required-message="please enter phone number." required="" id="phone" name="phone" placeholder="your phone *" class="form-control" value=""> <p class="help-block text-danger"></p> </div> </div> <div class="col-md-6"> <div class="form-group"> <textarea data-validation-required-message="please enter message." required="" id="message" name="message" placeholder="your message *" class="form-control" style="height:132px;" value=""></textarea> <p class="help-block text-danger"></p> </div> </div> <div class="col-lg-12 text-center"> <div id="success"></div> <input id="submit" name="submit" type="submit" value="send" class="btn btn-primary" /> </div> <div class="form-group"> <!-- used display alert user --> </div> </div> </form> <!-- end mailer -->
here url picture showing parameters populating in network mode (firebug). **stack overflow won't let me post pictures due lack of reputation.
you concatenating wrongly, come js ;)
$body = "name: " + $name + "\r\n" + "e-mail: " + $email + "\r\n" + "phone: " + $phone + "\r\n" + "message: " + $message + "\r\n";
should be
$body = "name: " . $name . "\r\n" . "e-mail: " . $email . "\r\n" . "phone: " . $phone . "\r\n" . "message: " . $message . "\r\n";