Click here to Skip to main content
15,120,268 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can i call any php function onclick of any html button without using isset. if it can be done then what is the procedure.
Posted
Updated 20-May-21 23:55pm

1 solution

XML
<?php
if($_GET){
    if(isset($_GET['insert'])){
        insert();
    }elseif(isset($_GET['select'])){
        select();
    }
}

    function select()
    {
       echo "The select function is called.";
    }
    function insert()
    {
       echo "The insert function is called.";
    }

?>.


<input type="submit" class="button" name="insert" value="insert" />
<input type="submit" class="button" name="select" value="select" />

===============================================



<?php
 if($_GET['button1']){fun1();}
 if($_GET['button2']){fun2();}

 function fun1()
 {
   //This function will update some column in database to 1
 }
 function fun2()
 {
   //This function will update some column in database to 2
 }
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
  </head>
  <body>
    <button id="btnfun1" name="btnfun1" onClick='location.href="?button1=1"'>Update to 1</button>
    <button id="btnfun2" name="btnfun2" onClick='location.href="?button2=1"'>Update to 2</button>
  </body>
</html>




Try these 2 ways i think it will help for you...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900