This question already has an answer here:
it is possible to call PHP function using HTML element as call to JavaScript function, as
<?php
function fname() { code to be excuted }
?>
<input type="button" value="call php function" onclick="fname()" />
I tried what is written but it was not successful.
</div>
You can try to do something like this instead:
<?php
function f() {
echo "method called";
}
?>
<form action="" method="post">
<input type="submit" name="submit" value="Submit" />
</form>
<?php
if (isset($_POST['submit'])) {
f();
}
?>