Wordpress Email Form -


WordPress email form

Hi all

I am using this type I am an email form in many sites and it has always worked.

I have tried to use it in a WordPress site but it will not be

Is there any obvious reason why the approach will not work in any WordPress site?

I need an email form that does not reload the contact page because the form is below

html

  & lt; Form action = "#" id = "contact_form"> & Lt; Input type = "text" id = "name" placeholder = "name:" & gt; & Lt; Input type = "text" id = "email" placeholder = "email:" & gt; & Lt; Textarea id = "message" rows = "8" cols = "40" placeholder = "message:" & gt; & Lt; / Textarea & gt; & Lt; Input type = "submit" id = "submit" /> & Lt; Div id = "status" & gt; & Lt; P & gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Form & gt;   

jquery

  $ ('# submit'). Click (function () {// var nameVal = $ ('# contact_form #name') .val (); var emailVal = $ ('# contact_form #email'). Val (); var messageVal = $ ('# Contact_form #message '). Val (); // $ .post (' / contact_form.php ', {Name: nameVal, email: emailVal, message: messageVal}, function (data) {$ ("# position p") $ ("# Condition p"). Show (). FadeOut (3500); if (data index ('thanks') == 0) {document.forms [0] .reset (); }}};})   

php

  $ errors = array (); $ required_field = array ('name', 'email', 'message '); Foreign currency ($ required_field as $ field name) {if (! ($! POST [$ fieldname]) || empty ($ _ POST [$ F $ Name = explosion ('', 'name']); {$ errors [] = $ field name;}} if (empty ($ errors)) {$ name_field = trim (stripesah ($ _ POST ['name']) $ Name_field); $ Firstname = ucfirst ($ name [0]); $ email_field = trim ($ _ POST ['email'])) $ message = trim (strip slot ($ _ POST ['message']) ); // $ = "info@ttmt.org.uk"; $ theme = "email from website"; $ Body = "From: $ name_field \ nEmail: $ email_field \ nMessage: \ n $ message"; // mail ($ $ to $ $ theme, $ body); "Thank You $ First Name"; } Else {echo "please complete all."; }   

--- UPDATE ---

I have found a part of working in it.

The part of the problem was that jQuery could not get php.

I created a 'code' folder in WP-conntent and put php there and jquery looks like this.

  $ j.post ('wp-content / code / contactEngine.php', {theName: nameVal, email: emailVal, message: messageVal}, function (data) { < / Pre> 

Now I am getting the returned data form php file but the email has not been sent.

Will it not work in WP

  Mail ($ $ $ $ Subject $ $);    

You get $ _POST ['name' ]. Using other names for the input field will fix your problem, eventually you can get a better user experience. "The contact form 7" using Wordpress-plugin: -)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -