Javascript Submit is not Sending POST to php file -
i having trouble getting javascript hyperlink button post data php form email script. have tried doing several different ways, nothing seems work. appreciated. thank you.
my form code:
<form id="form" action="contactform.php" method="post" enctype="text/plain" > <fieldset> <label><strong>your name:</strong><input id="name" type="text" name="name"> </label> <label><strong>your phone number:</strong><input id="phone" type="text" name="phone"></label> <label><strong>your e-mail:</strong><input id="email" type="text" name="email"></label> <label><strong>your message:</strong><textarea id="message" name="message"></textarea></label> <div class="btns"><a href="contacts.html" class="button">clear</a><a href="#" onclick="document.getelementbyid('form').submit();" class="button">send</a></div> </fieldset> </form>
contactform.php:
<?php var_dump($_post); if (isset($_post['form'])) { $name = $_post['name']; $phone = $_post['phone']; $visitor_email = $_post['email']; $message = $_post['message']; $email_from = 'emailaddress@gmail.com'; $email_subject = "contact form submission"; $email_body = "name: $name\n" . "phone: $phone\n" . "messge: $message"; $to= 'emailaddress@gmail.com'; $headers= "from: $email_from \r\n"; $headers.= "reply-to: $visitor_email \r\n"; mail($to,$email_subject,$email_body,$headers); echo "thank interest. contact shortly."; }else{ echo "it didn't work."; } ?>
also, have var_dump @ beginning of php debugging purposes only. not going part of final code.
remove enctype="text/plain"
form tag, php doesn't support it.
Comments
Post a Comment