doulao3905 2017-05-01 16:17
浏览 136

HTML按钮和php文件

I have a website that I created and I need to have a button link to a php file for it to execute a python script. My problem is that when you click the button the script does not execute. This is what I have so far, anything will help! The php file is called minecraft.php and the python script is called py-mine.py.

<?php
$output = shell_exec('/var/www/html/py-mine.py');
?>

and a section of my html for the button:

<a href="minecraft.php">
<button class="bkg-navy-light border-hover-navy-light color-white color-hover-navy-light no-margin-left" ></a>
    <span class="icon-upload"></span>
        Minecraft
    </button>
<input type="submit" value="Button3" class="form-submit button medium bkg-black bkg-hover-turquoise color-white color-hover-white">
  • 写回答

1条回答 默认 最新

  • doulin2947 2017-05-01 16:28
    关注

    You should properly structure the HTML code:

    You can use a hyperlink:

    <a href="minecraft.php">A link to the PHP page</a>
    

    OR

    Use a button:

    <form action="minecraft.php" method="GET">
        <button class="bkg-navy-light border-hover-navy-light color-white color-hover-navy-light no-margin-left" type="submit">
            <span class="icon-upload"></span>
            A button to the PHP page
        </button>
    </form>
    

    In your current code you used mix of both with wrong syntax structure.

    Make sure you use one option.

    Also, your php shell_exec should call a shell command, which in your case should be python:

    <?php
    $output = shell_exec('python /var/www/html/py-mine.py');
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?