You are here: Re: Button to execute python script « PHP Programming Language « IT news, forums, messages
Re: Button to execute python script

Posted by Kimmo Laine on 02/02/07 09:51

"Ivan Marsh" <annoyed@you.now> wrote in message
news:pan.2007.02.01.19.50.28.774460@you.now...
> On Thu, 01 Feb 2007 11:34:07 -0800, elrondrules wrote:
>
>> I am pretty new to PHP and hence need your help!!
>>
>> I need to write a PHP that shows the user a button (button1) and a
>> series of check boxes and another button (button2)..
>>
>> If the button1 is clicked then I should launch a python script running
>> on the same linux box as the PHP..
>>
>> If any of the check boxes are checked and button 2 is clicked, then I
>> should launch another script..
>>
>> Is there any way to do this in PHP...
>
> No. PHP is a server-side scripting language.
>
> You need to use a client-side scripting language like JavaScript.

I don't think Ivan understood correctly, because it most certainly can be
done with php at the server. Just call the python script via exec() or
system() in the form handler, once you've detected that the button was
clicked.

<form action="execute_python.php" method="post">
<input type="submit" name="submit1" />
</form>

<form action="execute_python.php" method="post">
checkboxeses:
<input type="checkbox" name="foo1" />
<input type="checkbox" name="foo2" />
<input type="checkbox" name="foo3" />
<input type="checkbox" name="foo4" />
<input type="submit" name="submit2" />
</form>

execute_python.php should be something like

<?php
if(isset($_POST['submit1'])){
exec('/path/to/the/python/script/my_python.py');
}
if(isset($_POST['submit2'])){
exec('/path/to/the/python/script/my_other_python.py');
}
?>

Read more about command line and php:
http://fi2.php.net/manual/en/ref.exec.php

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация