• Hi all,

    I have a very strange problem, and I hope someone can help me out.

    I have created a very basic custom template, that contains a form, that is submtted back to the template.

    If I enter any data into the form fields then I get a 404 error back from wordpress.

    If I leave the form fields empty wordpress acepts the form (even if their are hidden fields).

    You can see for yourself here:

    https://blossombeinspired.com/test/

    submit the form without data and you’ll get a ‘form submitted okay message’, add anything to in the form field and it returns a 404.

    ANY help whatsoever appreciated, I have been trying to sort this for hours.

    PS form works fine when not part of wordpress, I have also tried other versions of wordpress (2.0), and also tried 2 different servers and the same thing happens.

    This is the code:

    if ($_SERVER[‘REQUEST_METHOD’] == GET){
    ?>
    <form action=”<?php echo $_SERVER[‘REQUEST_URI’]; ?>” method=”POST”>

    Name: <input type=”text” name=”name” value=””>
    <input type=”hidden” name=”foo” value=”bar”>

    <input type=”submit” value=”Submit”>
    </form>
    <?php
    }
    else if ($_SERVER[‘REQUEST_METHOD’] == POST){
    echo “form submitted okay”;
    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter analogue40

    (@analogue40)

    I haven’t solved this problem, but rather made a workaround based on another reply I found on these forums.

    Instead of creating a template and the creating a page in wordpress based on this template, I just added the following to the top of my file:

    <?php
    /* Don’t remove this line. */
    require($_SERVER[‘DOCUMENT_ROOT’].’/wp-blog-header.php’);
    ?>

    and then just following this just create the page like it was a wordpress template.

    Then, to get pretty URLS I manually added the .htaccess entries to point to the file in my theme folder, for instance:

    RewriteRule admin$ /wp-content/themes/mytheme/my_custom_template.php [L]

    this sends anyone who goes to mysite.com/admin to mysite.com/wp-content/themes/mytheme/my_custom_template.php

    and it finally works.

    If anyone needs any help let me know.

    Me too… has anyone found a solution to this? I can’t see why it wouldn’t work.

    I had this exact same problem, and the solution I came across was annoyingly simple – don’t submit a form field called “name”: change

    <input type="text" name="name" value="">
    to
    <input type="text" name="myName" value="">

    as soon as I did this, everything started working.

    iAn

    wow!! you’re great, man!

    Thread Starter analogue40

    (@analogue40)

    ianstapleton,
    Cheers for posting the solution to this, just came across this problem again and came back on the off chance someone had replied to this post.

    I can’t beleive how much time I wasted last time looking for a solution to this, installed multiple version of wordpress and all sorts.

    a40

    spiff06

    (@spiff06)

    Lots of wasted time here too, glad I found this post though. Thanks loads.

    Odd though, that a form with a name set to “name” would fail to parse. This has to be a WordPress cleanup issue, or a security “feature” perhaps? Did anyone investigate this?

    Awesome!! I was wrangling with this exact same issue. Changing the “name” field to something else fixed it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘posting form to custom template results in 404’ is closed to new replies.