Hi guys
I have an HTML page that has a form action which uses PHP. I would like to consolidate these two into one PHP index page. Is it possible?
Please find code below:
<html>
<h1 style="color:blue;">Title 1</h1>
<form action="htmltobash.php" method="get">
Circuit: <select name="circuitsp"><option value="A">A</option><option value="B">B</option></select><br>
Pod: <select name="podidsp"><option value="A">A</option><option value="B">B</option></select><br>
Setpoint: <input type="text" name="setpoint"><br>
<button type="submit" name="SubmitSetpoint" value="SubmitSetpoint">Set Setpoint</button>
<br>
<br>
<<h1 style="color:blue;">Title 2</h1>
<form action="htmltobash.php" method="get">
Circuit: <select name="circuitps"><option value="A">A</option><option value="B">B</option></select><br>
Pod: <select name="podidps"><option value="A">A</option><option value="B">B</option></select><br>
Power: <select name="power"><option value="On">On</option><option value="Off">Off</option></select><br>
<button type="submit" name="SubmitSetpower" value="SubmitSetpower">Set Power</button>
</form>
</html>
And the PHP
<?php
if (isset($_GET['SubmitSetpoint']) && $_GET['SubmitSetpoint'] == "SubmitSetpoint") {
$field1 = $_GET["setpoint"];
$field2 = $_GET["podidsp"];
$field3 = $_GET["circuitsp"];
echo "$field1 $field2 $field3";
$output = shell_exec("/path/to.sh '$field1' '$field2' '$field3'");
echo "<pre>$output</pre>";
}
elseif (isset($_GET['SubmitSetpower']) && $_GET['SubmitSetpower'] == "SubmitSetpower") {
$field1 = $_GET["power"];
$field2 = $_GET["podidps"];
$field3 = $_GET["circuitps"];
echo "$field1 $field2 $field3";
$output = shell_exec("/path/to.sh '$field1' '$field2' '$field3'");
echo "<pre>$output</pre>";
}
else
exit
?>