Form Submission Not Working In Custom Theme

WordPress uses Name, email post fields to do post comments, If you renamed the your form elements name attributes to be f-name and f-email then your issue will be resolved. I have made changes in below code and it is working now.

<?php 
if($_POST['f-submit']) {

    if(!$_POST['f-name']) {
        $error="<br>- Please enter your name";
    }
    if(!$_POST['f-email']) {
        $error.="<br>- Please enter your email";
    }
    if(!$_POST['f-telephone']) {
        $error.="<br>- Please enter your telephone number";
    }
    if(!$_POST['f-message']) {
        $error.="<br>- Please enter your message";
    }
    if(!$_POST['f-checkbox']) {
        $error.="<br>- Please confirm you agree to the Privacy Policy";
    }

    if ($error) {
        $result="<div class="alert error">Whoops, there is an error. Please correct the following: ".$error.'</div>';
    } else {
        mail("[email protected]", "Contact Message", "Name: ".htmlspecialchars($_POST['f-name'])."
        Email: ".htmlspecialchars($_POST['f-email'])."
        Telephone: ".htmlspecialchars($_POST['f-telephone'])."
        Company: ".htmlspecialchars($_POST['f-company'])."
        Budget: ".htmlspecialchars($_POST['f-budget'])."
        Message: ".htmlspecialchars($_POST['f-message']),
        "From: [email protected]\r\n"
    );

        {
            $_POST= array();
            $result="<div class="alert thankyou" role="alert">THANK YOU! WE\"LL BE IN TOUCH SHORTLY...</div>';
        }

        $headers = "From: [email protected]\r\n";

    }
}
?>

HTML

<form id="contactform" method="post" action="#section-2">
        <?php echo $result; ?>
        <div class="form-row-1 js-st">
            <input id="name" type="text" name="f-name" placeholder="Name" value="<?php echo $_POST['f-name'];?>">
            <input id="email" type="email" name="f-email" placeholder="Email Address" value="<?php echo $_POST['f-email'];?>">
        </div>
        <div class="form-row-2 js-st">
            <input id="telno" type="text" name="f-telephone" placeholder="Telephone Number" value="<?php echo $_POST['f-telephone'];?>">
            <input id="company" type="text" name="f-company" placeholder="Company [optional]" value="<?php echo $_POST['f-company'];?>">
        </div>
        <div class="form-row-3 js-st">
            <textarea id="project-details" name="f-message" placeholder="Tell us about your project"><?php echo $_POST['f-message'];?></textarea>
        </div>
        <div class="form-row-4 js-st">
            <input id="budget" type="text" name="f-budget" placeholder="Budget" value="<?php echo $_POST['f-budget'];?>">
            <p class="budget-subline tl ">*We recommend putting in an approximate budget</p>
            <input id="privacy-checkbox" type="checkbox" name="f-checkbox"><label id="privacy-label" for="privacy-checkbox">I agree to the <a href="https://wordpress.stackexchange.com/questions/360610/./privacy.php">privacy policy</a></label>
        </div>
        <input class="js-st" id="formsubmit" type="submit" name="f-submit" value="SUBMIT">
    </form>