Site icon Hip-Hop Website Design and Development

How a HTML type can set off a PHP perform?

I am new to the WordPress/PHP world. I would like my web page have the ability to talk with an API that I construct myself. So for this I’ve a type on my WordPress Web page utilizing a HTML code widget which appears like this:

<html>
<physique>
    <div>
        <type id="myform" motion="submit_shortcode">
            <enter kind="text" id="input" placeholder="Input" required>
            <enter kind="submit" worth="Enter">
        </type>
    </div>
</physique>
</html>

And I’ve added this code to features.php of the present theme:

perform get_shortcode($sc) {
    $response = wp_remote_get('http://localhost:9000/shortcode/'.$sc);

    if (is_array($response)) {
        $physique = $response['body'];
        $knowledge = json_decode($physique);
        echo $knowledge;
        if (! is_wp_error($knowledge)) {
            echo "error";
        }
    }

    return;
}

add_action('submit_shortcode', 'get_shortcode');

However I am unable to see methods to combine the perform with the shape. After I submit my type, it sends me to mypage/submit_shortcode. How can I set off the perform get_shortcode when submitting the shape?

PS: This "shortcode" has nothing to do with the Shortcode widget of Elementor