I have an apache server on a raspberry pi. I have a basic program where the user inputs a string into an html form box. Clicking submit sends the entry to a php file, which then calls a shell script, and passes the entry as a prompt. If you look at the php below, it has a variable with the user input, and it calls the shell file main.sh. How can I provide the shell program that variable as an input. I have looked at proc_open, but haven't been able to get it to work. Thanks Index.html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="script.php" method="post" enctype="multipart/form-data">
Address: <input type="text" name="Address" value=""><br>
<input type="submit" value="Upload" name="submit">
</form>
</body>
</html>
script.php:
<?php
if(isset($_POST["submit"])) {
if($_POST['Address'] != "")
{
$entry = $_POST['Address'];
$output = shell_exec ("./main.sh");
echo $output;
}
}
?>
and finally the shell file: main.sh:
echo -n "Do you like pie (y/n)? "
read answer
if echo "$answer" | grep -iq "^y" ;then
echo Yes
else
echo No
fi