我想在我的服務器上從單選按鈕執行一個bash腳本並在我的網頁上提交按鈕。有兩個單選按鈕,每個都會執行不同的bash腳本(test1.sh test2.sh)。這是我到目前爲止。使用php執行bash腳本的HTML表單單選按鈕。
網頁HTML:
<form action="testexec.php" method="get">
<label class="col">Up/Down</label>
<span class="col">
<input type="radio" name="option" id="r1" value="1" />
<label for="r1">Up</label>
<input type="radio" name="option" id="r2" value="2" />
<label for="r2">Down</label>
</span>
<span class="col">
<input type="submit" />
</span>
test1.sh/test2.sh(在/ var/www/html等/ testscripts)
#!/bin/bash
touch /tmp/testfile
ls -ltr /tmp
testexec.php(同一目錄中我網頁)
<?php
$output = shell_exec("/var/www/html/testscript/test.sh");
header('Location: http://psat/moslehpour/dadt/main/systemTest.php?
success=true');
echo "<pre>$output</pre>"
?>
當點擊提交按鈕時,我在服務器端看不到任何操作。另外,我如何驗證正在發生的事情,我試圖回顯到網頁,但似乎沒有顯示。
如果你想看到你的輸出,你需要刪除重定向 –
你也叫你輸入字段都「選項」,這將只是發送選項= 2。你必須將其更改爲選項[],並在你的PHP腳本$ _GET [選項] [0],$ _GET [選項] [1]獲得的值或只是他們的名字diefferently –
@MarouenMhiri當我設置的選項選項1和選項2,它將允許我選擇兩個單選按鈕。我如何設置選項以僅允許用戶選擇一個選項? – kkmoslehpour