在wordpress中获取post方法不起作用

I have made a site in Wordpress.

In my front-page.php and in my index.php files I entered both post and get methods just to echo a message in page-message.php file.

When I click the subscribe button the posts page:news appears.The posts page:news is defined in my Wordpress settings: dashboard=>settings=>reading=>Front page displays=>a static page.

In page-message.php I wanted to show the data I had entered from this form. T

Code for the forms:

<h2>Sign to Newsletter</h2>
<form action="page-message.php" method="post">
    Name:<input class="input" type="text" name="name" value=""/><br/>
    Email:<input type="text" name="email" value=""/>
    <br/><input class="submit" type="submit" value="Subscribe"/>
</form>

Code for page-message.php:

<?php
    $name = $_POST["name"];
    $email = $_POST["email"];
    echo 'Congratulations!You have been successfully subscribed to our newsletter' .$name .$email;                
?>

When I click the subscribe button my url changes to http://localhost/wordpress/page-message.php?name=stergios&email=something%40someone.com.

This seems to be correct when using the post method. The problem is the content!

It always loads the news (posts page from settings =>reading) and not the simple echo message?

It always shows the posts page when I write anything beyond my pages in the url. For example the url localhost/wordpress/hhhhhhhhhhh (a page that does not exist) does load the posts page and not a message error!

I know the reason why it is not working.

action="page-message.php"

your static page's path should be /wp-content/themes/{themename}/page-message.php u can try it,

 action="<?php echo get_template_directory(); ?>/page-message.php"

But I don't think it will work. You can try

 action="/index.php"

It is untested. let me know if it work.

Update: As you set that page as front page, then your wordpress root url will be that page's url (example.com or example.com/wpdirectory). Then simply do it,

action="/"

or

action="/wpdirectory"

if "page-message.php" is a custom template in your theme you can get the page ID where it is assigned to with following query:

$get_message_pageId = new WP_Query(array(
    'post_type'  => 'page',
    'meta_key'   => '_wp_page_template',
    'meta_value' => 'page-message.php'
));

and then you can set the action with:

action="<?php echo esc_url( get_permalink( $get_message_pageId->posts[0]->ID ) ); ?>"

so you will always have the correct URL in your form, but it will only work if you have 1 page where this template is assigned to