PHP表单使用$ _SERVER [“PHP_SELF”]提交但从网址中删除.php

I am working on a php form that will use $_SERVER["PHP_SELF"] to submit to the same page. i am using .htaccess file that takes the file name and it will take off the .php extension so my url looks like this: http://example.com/contact instead of http://example.com/contact.php......

when i remove the .php from the form action it refreshes the page but a SERVER['post'] is not recorded..

what am i doing wrong??

php code to record if a post request was sent

if($_SERVER['REQUEST_METHOD'] == 'POST'){
    echo 'POST WORKS';
}

form

<form action="<?php echo '/'.htmlspecialchars(basename($_SERVER["PHP_SELF"], '.php'), ENT_QUOTES, "utf-8"); ?>" method="post" name="contact-form" id="contact-form" class="contact-form">

    <div class="columns-2 float-left">
        <label for="name">Your name <span class="required-text orangeText">(Required)</span></label>
        <input name="name" id="name" type="text" class="" value=""/>
    </div>

    <div class="columns-2 float-right margin-0">
        <label for="email">Your email <span class="required-text orangeText">(Required)</span></label>
        <input name="email" id="email" type="text" class="" value=""/>
    </div>

    <div class="columns-1 margin-0">
        <label for="message">Your message <span class="required-text orangeText">(Required)</span></label>
        <textarea name="message" id="message"  type="text" class=""></textarea>
    </div>

    <div class="columns-1 float-right margin-0 submit-btn-container">
       <input name="submit" type="submit" id="submitbtn" value="Send your message"/>
    </div>
</form>

htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

this was also a problem

echo '/'

No need for that in there