WordPress.org

Ready to get started?Download WordPress

Forums

Creating your HTML forms causes problems (6 posts)

  1. worchyld
    Member
    Posted 8 years ago #

    I've created my own template which is basically a form. The data is meant to go back to the same page and do all the processing necessary.

    However, for some reason when I put 'action="<?=$PHP_SELF;?>" it always go's back to the index.php and not to the actual page.

    I've tried hard-coding the actual page URL (ie: /?page_id=6) into the form, but it always go's to index.php

    I tracked down the page it's going to, it's calling "single.php" in the theme directory, but I do not why.

    So, in summary.

    1. Created a new .php in the theme's directory (ie; contact page)
    2. Associated a page created in WP to the new theme I created in point 1.
    3. Make the page have a form which sends data back to itself using $PHP_SELF or $_SERVER['PHP_SELF'];
    4. Doing this makes the data go to index.php
    5. Making the page go to "?page_id=7" still makes it go to index.php

    Why can't I send data back to the same page? How do I solve this?

  2. MichaelH
    Member
    Posted 8 years ago #

    You might look here for an explanation:
    Template_Hierarchy

  3. worchyld
    Member
    Posted 8 years ago #

    Thank you for your help.

    I recently made a "contact form" .php file which sits as a template in my themes directory.

    Amazingly, this form works -- but no other form does, which I found very strange - but I'm sure you're link will help.

    Thanks!

  4. worchyld
    Member
    Posted 8 years ago #

    I have now solved the problem -- for some reason an empty $PHP_SELF will make it go back to the same page, but if you put in a normal address it goes elsewhere...

  5. Monika
    Member
    Posted 8 years ago #

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>">

    this works for me fine
    kindly regards
    Monika

  6. worchyld
    Member
    Posted 8 years ago #

    Yes, but that is a get, my form used a post -- either way it is working now, and I am happy!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.