Q:

Run PHP code with click on Button

I need to run php code when I click on btn.
my Html code:
<button type='button'>Run my PHP code</button>

my php code (run when click on btn) :
<?php
   echo "Click On YesBtn";
?>

A:

If the button is in a .php page you can simply do:
<button type='button' onclick="document.write('<?php echo "Click On YesBtn"; ?>');>Run my PHP code</button>

if your php code is in a sepprate file you have to submit it with a GET/POST ect. request. Like so:
<form method="post" action="welcome.php" id="form1">       
    <button type="submit" form="form1" >Run my PHP code</button>
</form>

.
.
.
//welcome.php
<?php
   echo "Click On YesBtn";
?>

