HI i am beginner in PHP and really need some help

<head> 
<title>My Variables HTML Form</title> 
</head> 
<body> 
<h4>My HTML Form</h4> 
<?php
function display()
{
	echo "you called display function";
}

function profile()
{
	echo "you called Profile function";
}
?> 	
	

<form action="<?= $php_SELF ?>" method="POST">

        <input type="button" name="action" value="submitted" onClick="<? display() ?>" />
    <input type="button" name="submit" value="submit me!" onClick="<? profile() ?>" />

</form>



</body> 
</html>

it could not work at all. what i want is to call the function according to what i have clicked.
how to solve my problem?

thanks

Hello.

You have to check which button is closed :

<?php
      if(isset($_POST['action'])) { display(); }

      if (isset($_POST['submit'])) { profile(); }

?>

- Mitko Kostov

MitkOK is right with his code; but you have bigger problems before that:
- first of all, don't mix javascript function calls with php defined functions; get rid of those onClick="<? ....; those are javascript functions calls, but the functions you defined are php
- second: avoid using short open php tags (<?); use instead the long ones (<?php) that work on every server configuration;
Your code might work just fine without any correction (just with MitkOK addon code), but if you try to learn something here, than you should take the above into account.

This article has been dead for over six months. Start a new discussion instead.