PHP MySQL没有提交或工作

I have some PHP and HTML code which should send data from the form to my MySQL database. However, on clicking Submit in the form, the page reloads and nothing happens. No echo or anything. The HTML is in the same file as the PHP file.

PHP

<?php 
if(isset($_POST['submit'])){
    $usernamep = $_POST['usernameinput'];
    $passwordp = $_POST['passwordinput'];

    $servername = "localhost";
    $username = "USERNAMECENSOR";
    $password = "PASSWORDCENSOR";
    $dbname = "database";

    try {
        $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        // set the PDO error mode to exception
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "INSERT INTO accounts (username, password)
        VALUES ('$usernamep', '$passwordp')";
        // use exec() because no results are returned
        $conn->exec($sql);
        echo "Success";
    }
    catch(PDOException $e)
    {
        echo $sql . "<br>" . $e->getMessage();
    }
    $conn = null;
}
?>

HTML

<form method="POST" action="">
    <input type="text" name="usernameinput"><br>
    <input type="password" name="passwordinput"><br>
    <input type="submit" class="button" value="Sign in">
</form>

Note: I know this code is currently subject to SQL injection, and the password is not encrypted. It is temporary starting code in an attempt to get it working first.

You lack the name attribute in the submit button, add name="submit".

<form method="POST" action="">
    <input type="text" name="usernameinput"><br>
    <input type="password" name="passwordinput"><br>
    <input type="submit" name="submit" class="button" value="Sign in">
</form>

You have to include your php file into the action of the form tag.

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']?>">
   <input type="text" name="usernameinput"><br>
   <input type="password" name="passwordinput"><br>
   <input type="submit" class="button" value="Sign in">
</form>

Your test is wrong. You have no input named "submit" (with attribute name = submit). It should be:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
...
}

A broad test like this will not even need a named submit. The HTML form may even be posted on another event using jQuery or JavaScript.

In your PHP file, you use isset($_POST['submit']). You don't have any form input with name="submit". You could make your submit button be

<input type="submit" name="submit" class="button" value="Sign in">