i have created a button in my form (type=button) and on the onClick event, I need to execute some php code or some particular function
I don't want to create a submit button instead because cause i want to call different function when different button clicked how should i do that?
Code:
<head>
<title>My Variables HTML Form</title>
</head>
<body>
<h4>My HTML Form</h4>
<?php
if (isset($_POST['action']) && $_POST['action'] == 'submitted') {
echo "SUBMITTED BUTTON";
//calling function
display();
}
else {
echo "ME BUTTON";
profile();
}
function display()
{
echo "you called display function";
}
function profile()
{
echo "you called Profile function";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Name: <input type="text" name="personal[name]" /><br />
Email: <input type="text" name="personal[email]" /><br />
<input type="button" name="action" value="submitted" />
<input type="button" name="submit" value="submit me!" />
</form>
</body>
</html>
The program could not work and once runned it display directly " ME BUTTONyou called Profile function" how to correct the program so it runs only when it clicked according to the button triggered?
|