I am trying to get a value of a text field after clicking a button from html in php. I tried it with the get and post method, but nothing worked. My code is:
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<div class="btn-group" role="group" aria-label="...">
<form method="post">
<input type="submit" name="test" id="test" class="btn btn-info" value="RUN" /><br/>
</form>
</div>
<div class="formoutline">
<form action="" method="get">
<input name="subject2"type="text" id="subject2" class="form-control" />
</form>
</div>
<?php
function testfun()
{
echo $_GET["subject2"];
}
if(array_key_exists('test',$_POST)){
testfun();
}
?>
Can anyone help me?