Title: simple form post problem
Last modified: August 19, 2016

---

# simple form post problem

 *  [osura](https://wordpress.org/support/users/osura/)
 * (@osura)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/simple-form-post-problem/)
 * First time creating a theme from scratch.
 * I’ve built a form (simple one):
 *     ```
       <form name="cform" method="post" action="<?php echo bloginfo('template_directory') . '/contact-form.php' ?>">
   
       <fieldset>
         <input id="cname" name="cname" type="text" value="Name" />
         <input id="cemail" name="cemail" type="text" value="Email" />
         <input id="cphone" name="cphone" type="text" value="Phone" />
         <textarea id="cmessage" name="cmessage" rows="6" cols="33">Message</textarea>
         <button id="submit" type="submit" name="submit">Send</button>
       </fieldset>
   
       </form>
       ```
   
 * PHP I’m using to process the form:
 *     ```
       <?php
       if(isset($_POST['submit'])) {
       $to = "myemail@gmail.com";
       $subject = "Capital Care Contact Form";
       $name_input = $_POST['cname'];
       $email_input = $_POST['cemail'];
       $phone_input = $_POST['cphone'];
       $message = $_POST['cmessage'];
   
       $body = "From: $name_input\n E-Mail: $email_input\n Phone: $phone_input\n Message:\n $message";
   
       echo "Data has been submitted to $to!";
       mail($to, $subject, $body);
       } else {
       echo "blarg!";
       }
       ?>
       ```
   
 * I don’t know why but when I submit a test form I get a 404 the page cannot be
   found error.
 * Any ideas why WordPress thinks the file is missing?
 * Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [osura](https://wordpress.org/support/users/osura/)
 * (@osura)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1370828)
 * Is there a security feature in WordPress that doesn’t allow access to files in
   the template directory?
 * Or maybe the mod rewrite rules wordpress writes is causing the 404.
 * I searched for hours and this must be a simple fix.
 * Thanks in advance!
 *  Thread Starter [osura](https://wordpress.org/support/users/osura/)
 * (@osura)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1370896)
 * So I created a test.html page in my template root. In contact.php (a custom template
   page) I inserted a anchor link to test test.html:
    `<a href="<?php echo bloginfo('
   template_url') . '/test.html' ?>"> test</a>`
 * It opens and renders just fine. So why do I get a 404 when I do the same for 
   a php file I create. Surly there is a way to create your own php files and link
   to them from other php files.
 *  Thread Starter [osura](https://wordpress.org/support/users/osura/)
 * (@osura)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1370953)
 * I’ve obviously over estimated this problem. I looked and searched and searched,
   every few months some one posts a problem like this, and no one replys.
 * Maybe WP 3.0 will allow you to link to other php files in your template root
 *  Thread Starter [osura](https://wordpress.org/support/users/osura/)
 * (@osura)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1370969)
 * Turns out it is a .htaccess issue. I guess wordpress is writing some rules that
   restricts putting static pages into theme directory. I put the contact-form.php
   in the site root rather then template root.
 *  [Trevsweb](https://wordpress.org/support/users/trevsweb/)
 * (@trevsweb)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1371077)
 * I’m getting the same issue. with using a custom template/ page.
 * works fine when I don’t use anything within the form (error works fine)
    but 
   when theres something within the form it 404s 🙁
 * will follow your guidance with the site root but need to now work out how to 
   theme a root file :/
 * sorry for mega bump

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘simple form post problem’ is closed to new replies.

## Tags

 * [form](https://wordpress.org/support/topic-tag/form/)
 * [linking](https://wordpress.org/support/topic-tag/linking/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [templatepath](https://wordpress.org/support/topic-tag/templatepath/)
 * [template_directory](https://wordpress.org/support/topic-tag/template_directory/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 5 replies
 * 2 participants
 * Last reply from: [Trevsweb](https://wordpress.org/support/users/trevsweb/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/simple-form-post-problem/#post-1371077)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
