What is the right way to add a form to my plugin?

[ad_1]

When I search for information regarding creating a form for a plugin, all I get is a list of WordPress plugins. Is there not a standard way to do this?

I've been trying to create a form using a shortcode but the form displays above the header. I found some information on adding some surrounding code to make it load in the right place but it's not working.

public function load_shortcode()
{ 
    ob_start(); ?>

    <h1>Information</h1>
    <p>Fill out this form</p>
    <form>
        <input type="text" placeholder="Name">
        <input type="email" placeholder="Email">
        <textarea placeholder="Hello"></textarea>
    </form>

    <?php
        $output = ob_get_contents();
        ob_end_clean();
}

What is the right way to add a form to my plugin?

Thank you.

[ad_2]
2 Comments
  1. Why not just use a plugin? Accepting user input can be quite dangerous if you aren’t an experienced developer who’s familiar with escaping and sanitisation procedures.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer