Support » Plugins » Problem (rewrite?) with URI passed from a form

  • Any help will be greatly appreciated, I am at a loss here…

    I have written a simple PHP registration form for my blog and inserted it in a file called optin.php (see below). I have placed the file in my theme directory and then added an empty page called Registration, using optin.php as a template (so all the content of the Registartion page comes from optin.php).

    So far so good, the form displays just fine. However I can’t get it to redisplay with the confirmation part after I have submitted the form. I am receiving either a 404 Not Found or “article not found” messages, depending on the value I place in the action= atribute of my form. I have tried about everything…

    Here is my optin.php code (simplified for clarity) :

     * @package WordPress
     * @subpackage My_Theme
    Template Name: Optin
    <?php get_header(); ?>
    <div id="content" class="widecolumn">
       <div class="myClass">
          /* some text here */
             if ($_POST['submit'])
                /* here goes the part to display after form submission */
                /* I never managed to redisplay the page to show it... */
                print '<form id="contact" method="post" onsubmit="return validateForm()" onreset="clearErrorMessages();" action="">';
                /* the rest of the HTML code for the form comes here */
                /* this part displays correctly                      */
                print '</form>';
    <?php get_sidebar(); ?>
    /* This is the javascript that does form validation with the     */
    /* onsubmit and onreset functions referenced in <form> above     */
    <script type="text/javascript" src=""></script>
    <?php get_footer(); ?>

    What should the value of action= be for the page to redisplay after the form has been submitted?

    The only rewrite rules I have is the standard WP stuff and I only use one .htaccess file (no other rewrite rules elsewhere):

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    I am stuck, please help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • OK, just in case you had a similar problem, I found a solution:


    Using the page ID in the URL parameter string did the trick.

    It still would not work with the page name though, i.e.


    results in the 404 Not Found error. I still don’t know why – the value is exactly what WordPress uses as the link for this page in my sidebar! If I request this URL from a browser, the page displays correctly. So the URL gets rewritten somehow in the process, I just can’t figure where.

    Anyway, problem solved, case closed.

    Sorry, I thought it was fixed, but it’s not!

    I am getting a totally erratic behavior, it worked for a while and now I am getting the same error messages as before – without changing anything in the confirguration or the code…

    Any experts out there?


    I am experiencing this same problem. Form setup on a template page (contact.php) will not redisplay the same page to process the form data / display confirmation. This is how I have always coded forms in php using something like action=”<?=$_SERVER[‘PHP_SELF’]?>” because of the RewriteRule with wp I have also tried <?=htmlentities($_SERVER[‘REQUEST_URI’])?> Which seems to of worked for this guy I’ve also tried placing the direct http:// link to the ?page_id, or using the_permalink() as the form action. Even setting action=”” the form loads index.php?page_id=6 to process the form. Hence the page is blank after submission and the form html in contact.php is not displayed. I am quite confused :\

    Anyone have any insight here?

    I’m also experiencing this problem. I’ve tried exactly the same methods as jamesmehorter. This drives me nuts! I just get redirected to the blog post page, even though the correct URL displays in the addressfield.

    I think I’ve solved this problem. When I changed the names of my input elements it worked. I used input field names like “name” and “email”. Simply changeing those solved my problem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem (rewrite?) with URI passed from a form’ is closed to new replies.