'PHP $_POST not being recognized

Just recently picked up PHP for a project, currently I'm trying to get PHP to recognize when the submit button has been hit and to print "Success" using the code below (Ignore the fetchIntervals() that calls a javascript function):

<button class = "button" type = "submit" name = "submit" onclick = "fetchIntervals()" method = "POST">Submit</button>
    <?php
        echo("Test"); //Prints out successfully 
        if($_SERVER['REQUEST_METHOD'] == "POST"){ 
            echo("Post"); //Does not print
            if(isset($_GET["submit"])){
                echo("Success");
            }
        }
        if($_SERVER['REQUEST_METHOD'] == "GET"){
            echo("Get"); //Prints successfully even though I'm using POST method
            if(isset($_GET["submit"])){
                echo("Success"); //doesn't print at all when button is pressed
            }
        }
    ?>

As said in the code I know it's entering into the PHP block since "Test" successfully prints out, but even though I'm using method = "POST" for my button the $_SERVER['REQUEST_METHOD'] == "GET" is returning true and it's not even registering the button being clicked.

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source