Note that there are some explanatory texts on larger screens.

plurals
  1. POLinking to a custom .php file in custom Wordpress theme
    primarykey
    data
    text
    <p>I'm working on a Wordpress theme that has a Jquery animated contact form in it. I've got the js working (a div that's gets shown/hidden on click, with the form in it). Here's a static HTML/PHP <a href="http://www.stefanhagen.nl/" rel="nofollow" title="example">example</a> (click the 'contact' button). What's the problem you say? The problem is that the actual form does not get send. I've got the php file 'contact engine.php' that sends the form inside a folder called 'php' in my template directory. In the HTML i've got:</p> <pre><code>&lt;form method="post" action="&lt;?php bloginfo('template_directory'); ?&gt;/php/contactengine.php"&gt; &lt;label for="Name"&gt;Name:&lt;/label&gt; &lt;input type="text" name="Name" id="Name" /&gt; &lt;label for="Email"&gt;Email:&lt;/label&gt; &lt;input type="text" name="Email" id="Email" /&gt; &lt;label id="bericht" for="Message"&gt;Message:&lt;/label&gt;&lt;br /&gt; &lt;textarea name="Message" rows="10" cols="20" id="Message"&gt;&lt;/textarea&gt; &lt;input type="submit" name="submit" value="Submit" class="submit-button" /&gt; &lt;/form&gt; </code></pre> <p>After a bit of fiddling I've narrowed the problem down to the actual link to the php file. Wordpress does not send the input to the php-file, and nothing gets done. After some Google sessions I found that most people use a plugin for this, which I'm not a fan of. Also it seems that Wordpress does not let you write your own php snippets to implement in the theme. I've also found something that suggests I should put the php snippet in the functions.php file that comes with every template, but I wouldn't know how to link to a specific php snippet inside functions.php. Anyone knows how to solve this? Thanks in advance!</p> <p>P.S. The php script looks like this:</p> <pre><code>&lt;?php $EmailFrom = "contactformulier@stefanhagen.nl"; $EmailTo = "info@stefanhagen.nl"; $Subject = "Contactformulier StefanHagen.nl"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=error.htm\"&gt;"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; // $Body .= "Tel: "; // $Body .= $Tel; // $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: &lt;$EmailFrom&gt;"); // redirect to success page if ($success){ print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=../index.html\"&gt;"; } else{ print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=error.htm\"&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload