2015-08-27 3 views
-2

У меня есть форма на моей странице html, которая запускает php-страницу и показывает результаты в реальном времени на iframe, операция длится около 20 минут, я попытался реализовать вторую кнопку, которая останавливает запуск, убивая процесс, функция PHP работает, но проблема в том, что если я нажимаю кнопку остановки функция не start.Here в HTML:почему второй вход php submit не работает?

<div id="allign"> 
     <iframe id="frame" name="my_iframe" height="520" width="1100" allign="right" frameBorder="0" ></iframe> 
</div> 


<form action="action_calibration.php" method=post target="my_iframe"> 
<br><br> 
    <input type="radio" name="type" value="fast" checked>Fast Calibration 
<br><br> 
    <input type="radio" name="type" value="old">Old Calibration 
<br><br> 
    <input type="checkbox" name="ScanVPlus" value="yes" checked>Scan Vcth vs VPlus 
<br><br> 
    <input type="checkbox" name="Bitwise" value="yes">Bitwise Offset Tuning 
<br><br> 
    <input type="checkbox" name="All_channel" value="yes">Calibration using all channel 
<br><br> 
Output Folder:<input type="textfield" name="output" value="Results/"> 
<br><br> 
Hw Description File:<input type="textfield" name="Hw Description File " value="settings/Calibration2CBC.xml"> 
<br><br> 
    <input type="submit" name="exec" value="Submit"> 
    <input type="submit" name="exec1" value="STOP"> 
<br><br> 
</form> 

заключительная часть файла action_calibration.php как это:

$handle = popen("source ".$command, "r"); 
$continue=TRUE; 
while ((!feof($handle))&& $continue) { 
    $data = fgets($handle); 
    print $data."<br/>"; 
    echo $continue; 
    if(isset($_POST['exec1'])){ 
    $continue=FALSE; 
    } 
} 
shell_exec("kill $(pidof calibrate)"); 

Благодарим за помощь.

+0

Я думаю, вам лучше использовать 'break' нарушающего время цикла. Как 'if ($ _ POST ['exec'] ==" STOP ") { BREAK; } ' – Hearner

ответ

0

попробовать это ......

<input type="submit" name="exec" value="Submit"> 
<input type="submit" name="exec1" value="STOP"> 

$handle = popen("source ".$command, "r"); 
$continue=TRUE; 
while ((!feof($handle))&& $continue) { 
$data = fgets($handle); 
print $data."<br/>"; 
echo $continue; 
if(isset($_POST['exec1'])){ 
$continue=FALSE; 
} 
} 
shell_exec("kill $(pidof calibrate)"); 
Смежные вопросы