I have installed apache24 and php in freebsd 12.2. I have created a html form which takes two parameter such as IP Address & Hostname and then in sending these data to php server code. The server code is taking ip address and hostname and put in a text file. File is created but I want to run a shell script with a button like shell_exec() but is working.
how can execute shell_exec in php.
Code:
<!DOCTYPE HTML>
<head> DNS </head>
<body>
Welcome To DNS Configuration
<form action="dns.php" method="POST">
Enter IP Address:<br>
<input type="text" name="ip">
<br>
Hostname:<br>
<input type="text" name="hname">
<br><br>
<input type="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['ip']) && isset($_POST['hname']))
{
$data="{$_POST['ip']}\n{$_POST['hname']}\n";
$fp=fopen('dns.txt','w');
fwrite($fp,$data);
fclose($fp);
shell_exec('sh test.sh');
}
?>
how can execute shell_exec in php.