for odd reason, business input value won't submit email... it's blank.. can tell me what's wrong? thank you!
<?php // check empty fields if(isset(empty($_post['submit']) || empty($_post['email']) || empty($_post['phone']) || empty($_post['business']) || empty($_post['message']) || !filter_var($_post['email'],filter_validate_email)) { echo "no arguments provided!"; return false; } $name = strip_tags(htmlspecialchars($_post['name'])); $email_address = strip_tags(htmlspecialchars($_post['email'])); $phone = strip_tags(htmlspecialchars($_post['phone'])); $business = strip_tags(htmlspecialchars($_post['business'])); $message = strip_tags(htmlspecialchars($_post['message'])); // create email , send message $to = 'somekoreanguy@gmail.com'; // add email address inbetween '' replacing yourname@yourdomain.com - form send message to. $email_subject = "website contact form: $name"; $email_body = "you have received new message website contact form.\n\n"."here details:\n\nname: $name\n\nemail: $email_address\n\nphone: $phone\n\nbusiness: $business\n\nmessage:\n$message"; $headers = "from: noreply@yourdomain.com\n"; // email address generated message from. recommend using noreply@yourdomain.com. $headers .= "reply-to: $email_address"; mail($to,$email_subject,$email_body,$headers); return true; ?>
and here's html:
<form name="sentmessage" id="contactform" novalidate method="post"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <input type="text" class="form-control" placeholder="your name *" id="name" required data-validation-required-message="please enter name."> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input type="email" class="form-control" placeholder="your email *" id="email" required data-validation-required-message="please enter email address."> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input type="tel" class="form-control" placeholder="your phone *" id="phone" required data-validation-required-message="please enter phone number."> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input type="text" class="form-control" placeholder="your business name *" id="business" required data-validation-required-message="please enter business name."> <p class="help-block text-danger"></p> </div> <div class="col-md-6"> <div class="form-group"> <textarea class="form-control" placeholder="your message *" id="message" required data-validation-required-message="please enter message."></textarea> <p class="help-block text-danger"></p> </div> </div> <div class="clearfix"></div> <div class="col-lg-12 text-center"> <div id="success"></div> <button type="submit" name="submit" class="btn btn-xl">send message</button> </div> </div> </form>
for reason, when put "empty($_post['business']) ||" in there, nothing comes in email. when remove "type="text" business html section email goes through nothing value. it'll business: , blank....
you did not define method="post"
<form name="sentmessage" id="contactform" novalidate>
so
<form name="sentmessage" id="contactform" novalidate method="post">
give name
<button type="submit" name ="submit" class="btn btn-xl">send message</button>
so code
if(isset($_post['submit']){ //set code here }
Comments
Post a Comment