Site icon Hip-Hop Website Design and Development

Executing php on button press

I wish to create a button, which is able to execute the php code when pressed. The difficulty right here is the development like this doesn’t work:

<?php
    if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['someAction']))
    {
        func();
    }
    perform func()
    {
        echo 'pressed';   
    }
?>


<type methodology="post">
    <enter kind="button" identify="someAction" worth="press me"/>
</type>

It provides an error: "Expected tag name. Got ‘?’ instead"

Not surprisingly, an answer like this doesn’t work both:

<div class="mydiv"><?php do_shortcode("[shortcode_name]");?></div>

Nonetheless, the concept of utilizing the shortcode is definitely high quality, however it has to run the shortcode solely when the button is pressed.

I’ve additionally tried utilizing JavaScript for the button, which labored, however I do not know a straightforward approach to run the php code from JavaScript.

When you have any concept on how to do that, your solutions might be welcome.

Only for context, I’m utilizing elementor for this, the html block to be actual.