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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。