How to submit form in a PHP file in WordPress?

Question

I have a simple form in my WordPress footer.php:

<form class="form-inline" role="form" method="post" name="contact" action="sub.php">
    <div class="form-group">
        <label class="sr-only" for="my-name">Your first name</label>
        <input name="my-name" type="text" class="form-control" id="my-name" placeholder="Your first name">
    </div>
    <div class="form-group">
        <label class="sr-only" for="my-email">and your email</label>
        <input name="my-email" type="text" class="form-control" id="my-email" placeholder="and your email">
    </div>
    <input  type="submit" class="btn btn-danger" value="Subscribe!">
</form>

I want to submit it to the file sub.php(which is in same directory), as you can see in the action. But even after trying too many solution I still am not able to get the task done.

Please point me to the simplest solution. Thanks

0
thirteen4054 4 years 2020-03-25T00:53:47-05:00 0 Answers 107 views 0

Leave an answer

Browse
Browse