jack123 Posted November 18, 2013 Report Posted November 18, 2013 hi guys, I create a php form field to be sent to my email when submitted. However, it failed to send my phone field when I fill it out. Im not sure what is the issue, can you guys gives some advice? <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $phone = $_POST['phone']; $human = $_POST['human']; $email_to = "hello@something.com"; $email_subject = "web customer"; $formcontent = " From: $name \n email: $email \n Phone: $phone \n Message: $message"; if (($name=="") || (strlen($name)< 2)){ echo "Please fill in your name...(need to be more than 2 character)"; } else if (!filter_var($email, FILTER_VALIDATE_EMAIL)){ echo "E-mail address invalid!!"; } else if (($message== "") || (strlen($message)>250)){ echo "Message cannot be empty or greater than 250 characters..."; } else if ($human !='2'){ echo 'Sorry, your maths is wrong, please try again '; exit(); } else{ //header("location: ../thanks.html"); echo 'E-mail sent!! I will try my best to reply within 24 hours '; $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $formcontent, $headers); } ?> <html> <form action="mail.php" id="contact_form" method="POST" onsubmit="formReset();"> <ul> <li><input type="text" name="name" placeholder="Name" class="input_item field_name" id="name" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Name'" required value="" /></li> <li><input type="email" name="email" placeholder="Email" class="input_item field_email" id="email" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Email'" required value="" /></li> <li><input type="tel" name="phone" placeholder="Phone (optional)" class="input_item field_phone" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Phone'" value=""/></li> <li><textarea type="message" name="message" placeholder="Message" class="input_item field_message" id="message" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Message'" required value=""/></textarea></li> <li><input type="text" name="human" placeholder="What is 1+1? (Anti-spam)" class="input_item field_spam" id="human" onfocus="this.placeholder = ''" onblur="this.placeholder = 'What is 1+1? (Anti-spam)'" required value=""/></li> <li class="full"><button input type="image" value="" name="submit" id="button" onClick="javascript:ajax_post();" /></button></li> </ul> </form> </html> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.