php - Not sure why form is not sending email to my email -
i trying email form work , having problem figuring out why not go threw email address. when nail submit directed give thanks page if form sent correctly never receive email. don't know how debug figure out doing wrong , bugging me stuck on measly form problem. in case cant tell code using foundation framework.
any help appreciated, give thanks you.
here html
<div class="section4"> <div class="row"> <div class="small-12 medium-6 columns"> <form data-abide method="post" name="myemailform" action="formtoemail.php"> <h2>get in touch</h2> <div class="row"> <div class="large-8 columns"> <label>name <small>required</small> <input type="text" name="name" placeholder="your name" required pattern="[a-za-z]+"/> </label> <small class="error">name required , must string.</small> </div> </div> <div class="row"> <div class="large-8 columns"> <label>email <small>required</small> <input type="text" name="email" placeholder="your email" required/> </label> <small class="error">an email address required.</small> </div> </div> <div class="row"> <div class="large-8 columns"> <label>company <input type="text" name="company" placeholder="your company" /> </label> </div> </div> </form> </div> <div class="small-12 medium-6 columns"> <h2>don't hesitate leave message</h2> <div class="row"> <div class="large-12 columns"> <label>message <textarea name="message" placeholder="your message here"></textarea> </label> </div> </div> <input type="submit" name="submit" class="submit right" value="submit" /> </div> </div> </div><!-- end of section4 -->
and here formtoemail.php file
<?php if(!isset($_post['submit'])) { //this page should not accessed directly. need submit form. echo "error; need submit form!"; } $name = $_post['name']; $visitor_email = $_post['email']; $company = $_post['company']; $message = $_post['message']; //validate first if(empty($name)||empty($visitor_email)) { echo "name , email mandatory!"; exit; } if(isinjected($visitor_email)) { echo "bad email value!"; exit; } $email_from = $visitor_email;//<== update email address $email_subject = "new form submission"; $email_body = "you have received new message user $name.\n". "here message:\n $message". $to = "theller5567@gmail.com";//<== update email address $headers = "from: $email_from \r\n"; $headers .= "reply-to: $visitor_email \r\n"; //send email! mail($to,$email_subject,$email_body,$headers); //done. redirect thank-you page. header('location: thank-you.html'); // function validate against email injection attempts function isinjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0a+)', '(%0d+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { homecoming true; } else { homecoming false; } } ?>
php html forms
No comments:
Post a Comment