Jump to content

Onclick With Php


Grabeorama
 Share

Recommended Posts

Is it possible to call a PHP function with 'onclick'?like if I had:<input type="button" onclick="php_function()" value="click">or would it have to be in JS?
No, you cannot make a PHP function happen after the page is loaded. PHP is a Preprocessor.
Link to comment
Share on other sites

  • 4 weeks later...

I was facing the same problem and all I found was no for an answer. Well, surprise. Not exactly with onclick since that is JS, but there is way to basicly the same with PHP/HTMLHere is an example:

 <?phpfunction myfunction(){echo("<strong>I love PHP !</strong><br>");}?><a href="<?php echo("$PHP_SELF?execute=myfunction")?>">click to execute myfunction ! </a><p><?php if ( isset($execute) ){myfunction();}?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...