Forums

Custom Form and 404 Error (4 posts)

  1. arr
    Member
    Posted 1 year ago #

    Hi

    I'm brand new to WordPress so excuse the basic questions :) I am trying to add a contact form to a page. I want to do this manually rather than using a plugin mainly as I'm just trying to get my head around the whole process. Initially I want to avoid custom templates and just add a form into a standard page. I am pretty much working from the post at http://www.badlydrawntoy.com/2009/10/07/how-to-run-custom-php-code-in-wordpress-the-right-way/.

    So far I have added a plugin that allows me to run PHP code on a page. The code I have added simply contains the PHP command...

    require_once(ABSPATH. '/wp-content/custom-php/p2.php');

    p2.php conatins the following...

    <form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
      <div>
        <label for="name">name</label>
        <input type="text" name="name" id="name" />
      </div>
      <input type="submit" value="go" />
    </form>

    If I go to my site and access this page it opens up and shows the form so the include is working ... so far so good. If I click on the submit button with nothing in the input field then everything is still happy. The minute I put some text into the input field and click submit I get a 404 Page Not Found error. Can someone please suggest what might be going on?

    Thanks

    Alan

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    If you want to use this an an exercise to understand WP, then I'm afraid you will, effectively, have to write your own plugin. I'd suggest starting with Writing_a_Plugin.

  3. arr
    Member
    Posted 1 year ago #

    Thanks Esmi. I didn't really want to get that involved though :s At this stage all I really want to do is understand how to successfully enable a post back.

  4. arr
    Member
    Posted 1 year ago #

    Blimey I fixed it... WP doesn't seem to like it when I use name="name" for the input tag. I changed it to name="uname" and it now works. What a waste of a day!! Why didn't I google earlier :s

    http://wordpress.org/support/topic/contact-form-404-error?replies=8

Topic Closed

This topic has been closed to new replies.

About this Topic