WordPress.org

Ready to get started?Download WordPress

Forums

Form action to load same page doesn't work (9 posts)

  1. jbwp11
    Member
    Posted 1 year ago #

    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

  2. Peter_L
    Member
    Posted 1 year ago #

    try <?php the_permalink(); ?>

  3. jbwp11
    Member
    Posted 1 year ago #

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

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

  4. Peter_L
    Member
    Posted 1 year ago #

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

  5. jbwp11
    Member
    Posted 1 year ago #

    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.

  6. Peter_L
    Member
    Posted 1 year ago #

    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?

  7. jbwp11
    Member
    Posted 1 year ago #

    '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">
  8. Peter_L
    Member
    Posted 1 year ago #

    ?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).

  9. jbwp11
    Member
    Posted 1 year ago #

    ?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?

Topic Closed

This topic has been closed to new replies.

About this Topic