WordPress.org

Support

Support » How-To and Troubleshooting » Form action to load same page doesn't work

Form action to load same page doesn't work

  • I have been trying to have WP load the same page using SELF_PHP, REQUEST_URI, empty string etc but none seems to work. Using a full path of a .php file in the action works but I need to have it work for an html page (http://example.com/page_id=xx). The theme is “startupWP”.

    I get the following message:
    Not Found
    Nothing found for the requested page. Try a search instead?

    Code block:

    <form action="" method="GET"><input type="TEXT" name="name">
    <?php echo("http://"."$_SERVER[HTTP_HOST]"."$_SERVER[REQUEST_URI]"); ?>

    I printed out the following to test.
    $SELF_PHP prints empty string
    $_SERVER[REQUEST_URI] prints ?page_id=xx

Viewing 8 replies - 1 through 8 (of 8 total)
  • try <?php the_permalink(); ?>

    Same result:
    Nothing found for the requested page. Try a search instead?

    I have also tried register_globals on/off with the same result.

    Like this.
    <form action="<?php the_permalink(); ?>">
    Don’t you need method=”post” btw?

    I used method=”get”. It works if I link example.php instead of a page.

    <form action="<?php the_permalink(); ?>" method="GET">

    It doesn’t work even if I hardcode http://example.com/page_id=xx into the action.

    If it doesn’t work with a hardcoded url then the problem probably lies elsewhere. Perhaps you’ve accidentally enabled url redirect on submit?

    What page do you get directed to, when ‘Nothing found for the requested page. Try a search instead?’ is displayed?

    ‘Nothing found for the requested page. Try a search instead?’ page is
    http://example.com/?name=testname

    <form action="<?php the_permalink(); ?>" method="GET">
    <input type="TEXT" name="name">
    <input type="SUBMIT" value="Go">

    ?name=something …? That’s weird. Shouldn’t it be ?p=x or ?page_id=x?

    Where are you actually calling the form from? A page? A post?

    I have an active wordpress site with a form that calls itself. (<form action=”<?php the_permalink(); ?>” method=”POST”>)
    I placed it on a page template (page-{slug}.php).

    ?name=testname part comes from the an input box on the form (<input type=”TEXT” name=”name”>). Supplying “testname” in this text box leads to this webpage http://example.com/?name=testname

    It should instead load the page with the argument “?name=testname”

    Since hardcoding the page id does not work, can there be some other issue with this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Form action to load same page doesn't work’ is closed to new replies.