• 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 (https://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("https://"."$_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(); ?>

    Thread Starter jbwp11

    (@jbwp11)

    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?

    Thread Starter jbwp11

    (@jbwp11)

    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 https://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?

    Thread Starter jbwp11

    (@jbwp11)

    ‘Nothing found for the requested page. Try a search instead?’ page is
    https://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).

    Thread Starter jbwp11

    (@jbwp11)

    ?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 https://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.