This code is in first.php
function fas(){
echo "fuction";
echo "Anything";
}
if(isset($_POST['btn'])){
fas();
}
?>
Code in second.php
<?php
include 'first.php'
?>
<!DOCTYPE html>
<head>
<title>Document</title>
</head>
<body>
<button type= "submit" name = "btn"> click this</button>
</body>
</html>
On clicking the button, function fas is not getting called. What's the issue?
CodePudding user response:
You could put the button in a form
tag, then the button like this:
<form action="/" method="post">
<button type="submit">Submit</button>
</form>
Or you could do it like this:
<button onclick="function_name()">Submit</button>
The second one is going to call the function directly, and not go to a separate link like a form would.